Posted By: Anonymous
I want to compare file1 with file2 and generate a file3 which contains the lines in file1 which are not present in file2.
diff(1) is not the answer, but comm(1) is.
NAME comm - compare two sorted files line by line SYNOPSIS comm [OPTION]... FILE1 FILE2 ... -1 suppress lines unique to FILE1 -2 suppress lines unique to FILE2 -3 suppress lines that appear in both files
comm -2 -3 file1 file2 > file3
The input files must be sorted. If they are not, sort them first. This can be done with a temporary file, or…
comm -2 -3 <(sort file1) <(sort file2) > file3
provided that your shell supports process substitution (bash does).