I have 2 files,fileA and fileB.
fileA contains:
71
32
23
10
...
and fileB contains:
ok
no
no
ok
...
What I want to do is deleting lines in fileA if the same line in fileB matches ‘no’.
So the resulting fileA would like:
71
10
...
Any command or bash script or vim can do this?
Here’s a quick one-liner that ought to do the trick:
Where you put your regex to match where you see the word ‘no’ above.
It works by scanning over the first with awk, and printing the line number followed by the letter ‘d’ of where the matches are. This pattern of
ndis a sed command which deletes the nth line of an input stream.This version won’t modify the contents of fileA, but will print the result of removing the lines onto stdout. use the -i flag of sed to modify the file: