Hello!
I need to delete one line in a file which matches one very precise instance of a string only. When searching the forum I unfortunately only found a solution which would delete each line on which a particular string occurs.
Let's assume I have a file composed of thousands of lines and let's call the file chap-secrets. Let's take the following sample entries:
#USERNAME SERVER PASSWORD IP
pp pptpd blahblah *
cpp pptpd ppbbbbpp *
hopp pptpd ggmmsasm *
flopps pptpd 01234567890abcdef *
The usernames are unique, naturally.
I would now like to delete the line containing the username "pp" only. The following suggestion has been made in a related thread:
awk 'match($0,"pp") == 0 {print $0}' FILENAME > NEWFILENAME
However, this doesn't work here, for it would delete (or rather not store) all these lines, because all lines with the usernames "cpp", "hopp" and "flopps" are valid matches, all lines with the server name "pptpd" are valid matches and all lines where the password contains a "pp" (such as "ppbbbbpp") are valid matches, too, and these lines all would be deleted (or rather not stored) as well.
Note that the number of spaces between the fields differ as well all the time, so I can't search for a pattern like
"pp pptpd"
either.
I suppose this problem is very simple for some of you, but for me it's not, thus every help would be very much appreciated.
Thank you!