$ comm -23 file2 file1
— by Anon9ge6A4uD
on Feb. 13, 2012, 8:26 a.m.
The POSIX-standard comm utility can do this also.
Assumes that file1 and file2 are already sorted. If they are not, you can use process substitution to do so:
comm -23 <(sort file2) <(sort file1)
Process substitution is a bash-specific feature (also available in zsh but with a different syntax).
$ grep -vxFf file1 file2
— by Janos
on Feb. 8, 2012, 2:42 p.m.
The result is effectively the same as:
diff file1 file2 | grep '^>' | sed -e s/..//
The flags of grep might work differently depending on the system. So yeah you might prefer the second way which should work everywhere. Nonetheless the various of flags of grep are interesting.