Linux Grep the delta -
i have 2 files: file1, file2. want lines file2 don't exist in file1.
i have read post told me use -v flag of grep it(i read man page of grep still did not quite how use -f , -x flag), have no luck far.
$ cat file1 eric cartman kenny mccormick $ cat file2 stan marsh kyle broflovski eric cartman kenny mccormick $ grep -v file1 file2 stan marsh kyle broflovski eric cartman kenny mccormick
my expected output should this:
stan marsh kyle broflovski
this grep line may help:
grep -fvf file1 file2
or awk:
awk 'nr==fnr{a[$0]=1;next}!a[$0]' file1 file2
Comments
Post a Comment