Difference between two .tar.gz file lists on linux

Ganesan MP picture Ganesan MP · Oct 31, 2012 · Viewed 17.1k times · Source

Having two different .tar.gz files: The second .tar.gz is the subset of first .tar.gz.

I need a single line command to find the missing files in second .tar.gz.

E.g.:

1.tar.gz file list:

1.jsp
2.txt
3.htm

2.tar.gz file list:

1.jsp
3.htm

output should be:

2.txt

Answer

P.P picture P.P · Oct 31, 2012

Just list the contents and do diff:

diff <(tar -tvf 1.tar.gz | sort) <(tar -tvf 2.tar.gz | sort)