Skip to content
Advertisement

Difference between two files containing file names

I have two files, audit.txt and server.txt, both contain filenames. I want to get only filenames that are present in audit.txt but not in server.txt

audit.txt looks like

filename1
filename3
filename2

server.txt looks like

filename1
filename2

ideally i would want the difference in a 3rd file missing.txt that will contain filename3 as per the example above.

I have tried following but the missing.txt does not contain correct difference,

comm -13 audit.txt server.txt > missing.txt

Advertisement

Answer

You could use diff command like so

diff audit.txt server.txt > missing.txt
User contributions licensed under: CC BY-SA
4 People found this is helpful
Advertisement