Hello!

I have another issue that i cant solve.
How do i search after a string in a text file and remove it when it get a match?

Recommended Answers

All 3 Replies

Please try

cat YOURFILE | sed 's/YOURSEARCH//g' > YOURFILE.tmp
mv YOURFILE.tmp YOURFILE

Just replace "YOURFILE" with the name of the file to search in
and "YOURSEARCH" with the string you want to eliminate.

Please try

cat YOURFILE | sed 's/YOURSEARCH//g' > YOURFILE.tmp
mv YOURFILE.tmp YOURFILE

Just replace "YOURFILE" with the name of the file to search in
and "YOURSEARCH" with the string you want to eliminate.

OK but i dont know what to remove, its supposed to be a variable.
thanks for the help btw.

Will this syntax help
grep -vx $TELENUMMER nummer.txt >> nummerdelete.txt;;

If the file "nummer.txt" contains lines that exactly match the contents of the Variable "TELENUMMER" (no trailing blanks for instance) then these lines would not appear in the file "nummerdelete.txt", all others will.

By the way the two semicola at the end of your code are not necessary.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.