I have two text files, A and B:
A:
a start
b stop
c start
e start
B:
b
c
How can I find which lines in A are not started by lines from B using shell(bash…) command. In this case, I want to get this answer:
a start
e start
Can I implement this using a single line of command?
This should do:
The
sedcommand will take all non-empty lines (observe the/^$/dcommand) from the fileBand prepend a caret^in front of each line (so as to obtain an anchor forgrep‘s regexp), and spits all this tostdout. Then grep, with the-foption (which means take all patterns from a file, which happens to bestdinhere, thanks to the-symbol) and does an invert matching (thanks to the-voption) on fileA. Done.