Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Difference between two .tar.gz file lists on linux

Tags:

linux

tar

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
like image 458
Ganesan MP Avatar asked Oct 31 '12 11:10

Ganesan MP


People also ask

How can I tell the difference between two tar files in Linux?

execute a tar tvf to list the contents of each file and store the outputs in two different files. then, slice out everything besides the filename and size columns. Preferably sort the two files too. Then, just do a file diff between the two lists.

What is the difference between tar and tar GZ?

In short, a TAR file creates one archive file out of multiple files without compressing them, while the GZ file format compresses a file without creating an archive. Combined into the tar GZ file extension, you can archive and compress multiple files into one.

What are tarball files in Linux?

Introduction: A tarball (or tar.gz or tar.bz2) is nothing but a computer file format that combines and compresses multiple files. Tarballs are common file format on a Linux or Unix-like operating systems. Tarballs are often used for distribution of software/media or backup purposes.


1 Answers

Just list the contents and do diff:

diff <(tar -tvf 1.tar.gz | sort) <(tar -tvf 2.tar.gz | sort) 
like image 106
P.P Avatar answered Sep 17 '22 20:09

P.P