I am trying to remove matching lines from one text file using another. For example, fired.txt
contains:
Jason
Candice
Brent
Tom
And I want to remove matching lines from workers.txt
, which currently looks like this:
Andrew
Tommy
Peter
Jason
Brent
Sasha
Tom
Candice
So, in the end, it would remove the entire line if it matches exactly, so it would look like this:
Andrew
Tommy
Peter
Sasha
I am using macOS Sierra, btw.
Best Answer
Short grep approach:
The output:
grep options:
x
- Select only those matches that exactly match the whole linev
- Invert the sense of matching, to select non-matching linesf
(--file=file
) - Obtain patterns fromfile
, one per line