Reputation: 2067
I have two files where ifile1.txt is a subset of ifile2.txt.
ifile1.txt ifile2.txt
2 2
23 23
43 33
51 43
76 50
81 51
100 72
76
81
89
100
Desire output
ofile.txt
33
50
72
89
I was trying with
diff ifile1.txt ifile2.txt > ofile.txt
but it is giving different format of output.
Upvotes: 0
Views: 1309
Reputation: 659
You could try:
diff file1 file2 | awk '{print $2}' | grep -v '^$' > output.file
Upvotes: 1
Reputation: 780974
Since your files are sorted, you can use the comm
command for this:
comm -1 -3 ifile1.txt ifile2.txt > ofile.txt
-1
means omit the lines unique to the first file, and -3
means omit the lines that are in both files, so this shows just the lines that are unique to the second file.
Upvotes: 2