Shell -- elements in file1 but not in file2

Given two files with multi records in each. Each line is a record.
Find the records in file1 but not in file2

sort file1 | uniq > newfile1;
sort file2 | uniq > newfile2;
comm -12 newfile1 newfile2 > common
More about getting common elements of two files.

Use 'uniq' to get the elements in file1 but not in file2
cat common newfile1 | sort | uniq

No comments:

Post a Comment