Issue
I have two files, I need an output file which contains everything that is not in the first file but is in the second file, the second file contains everything that is in the first file with some more entries. I tried:
for j in `cat first`; do sed '/"$j"/d' second; done
cat first
a
b
c
d
e
f
# cat second
a
1
b
22
33
c
44
d
11
e
44
f
Solution
Converting my comment to answer so that solution is easy to find for future visitors.
You may use this grep
:
grep -vFxf first second
1
22
33
44
11
Options are:
-v
: Selected lines are those not matching any of the specified patterns-F
: Fixed string search-x
: Exact match-f
: Use a file for patterns
Answered By - anubhava Answer Checked By - David Marino (WPSolving Volunteer)