sdf
1
Have two files and want to compare the content of file1 with file2. When matched remove the line.
awk 'NR==FNR {b[$0]; next} !(b in $0)' file1 file2
file1
1. if match
2. remove
file2
1. this line has to be removed if match
2. this line has a match, remove
3. this line has no match, no removing
The code does not remove the matches.
CarloM
2
What exactly are you matching? None of those lines match...
If your grep supports -f then grep -vf file1 file2
(or vice-versa) may do what you want.
sdf
3
Two lines match and need to be removed with awk
negativlist
if match
remove
input
1. this line has to be removed if match
2. this line has a match, remove
3. this line has no match, no removing
output
3. this line has no match, no removing
sdf
4
This is what i was looking for. It prints only lines which do NOT match strings stored in a seperate file.
awk -FS=" " 'NR==FNR {b[$0]; next} {for (x in b) if($0 ~ x) next;print $0}'
Took me some hours but finally got the code.