Print the lines of file2 that are missing in file1

grep -vxFf file1 file2

February 8, 2012bashoneliners

Explanation

The meaning of the flags:

  • -v -- select non-matching lines
  • -x -- match complete lines
  • -F -- treat the patterns as fixed strings instead of regular expressions
  • -f FILE -- take patterns from FILE

All of these flags are critical to perform the intended task accurately.

Alternative one-liners

Print the lines of file2 that are missing in file1

comm -23 file2 file1

February 13, 2012Anon9ge6A4uD