6

Is there a way I can diff a gzipped tarball against an existing directory?

I would like to be able to do it without extracting the data from the tarball.

3

Mount the tarball as a directory, for example with AVFS. Then use diff -r on the real directory and the point where the tarball is mounted.

mountavfs
diff -r ~/.avfs/path/to/foo.tar.gz\# real-directory
  • 1
    What is the \# for? – Annan Oct 3 '12 at 17:59
  • 1
    @Annan AVFS exposes the contents of an archive as a directory whose name is the name of the archive file with a # appended. The backslash is unnecessary in most shells. – Gilles Oct 3 '12 at 18:05
0

Here is a new tool: http://diffoscope.org/

Older tool: http://tardiff.sourceforge.net/

4

Turns out that GNU tar has diff built in (-d):

$ #Create the archive and a difference:
$ echo one>file1;echo two>file2;tar -czf archive.tgz file*;echo changing>>file1
$ tar -dzf archive.tgz
file1: Size differs

If you are working with tar that does not have this try:

$ for F in `tar -tzf archive.tgz`;do tar -xzOf archive.tgz $F|diff --brief - $F;done
Files - and file1 differ

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.