File Comparison: Print Lines not present in another file

Hi,
I have fileA.txt like this.

B01B02	D0011718
B01B03	D0012540
B01B04	D0006145
B01B05	D0004815
B01B06	D0012069
B01B07	D0004064
B01B08	D0011988
B01B09	D0012071
B01B10	D0005596
B01B11	D0011351
B01B12	D0004814
B01C01	D0011804

I want to compare this against another file (fileB.txt) that has a subset of the lines in fileA.txt.

B01B02	D0011718
B01B03	D0012540
B01B07	D0004064
B01B08	D0011988
B01B09	D0012071
B01B10	D0005596
B01B11	D0011351

The output needs to have only the difference between the two files.
Output fileC.txt

B01B04	D0006145
B01B05	D0004815
B01B06	D0012069
B01B12	D0004814
B01C01	D0011804

Awk preferred, but can also do with python.
Thanks
~GH

Try:

awk 'NR==FNR {d[$0];next} ! ($0 in d) {print}' fileB.txt fileA.txt
1 Like

If the files are sorted, as they are in your sample data, then comm can do the job.

Regards,
Alister

The awk command worked fine..
For some reason neither comm or diff -a --suppress-common-lines worked for me.. not sure why.