Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to compare two tar archives (including file content, new/removed files, symlinks)?

Tags:

linux

symlink

tar

I have two tar archives (compressed or not compressed), and I want to find all differences in the two archives. Both archives contain a complete file system (i.e. when unpacked, would generate directories like /bin, /home, /root, /usr, /var, /etc,... I hope you get the point). I want to have a list of the following:

  • New files
  • Removed files
  • Changed files (content of file, not just size)
  • Changed symlinks (both relative and absolute)
  • New/removed symlinks

I cannot just unpack those archives and use diff, as diff will not correctly recognize absolute symlinks (as they would point out of the file system structure of the archive).

Is there another way to compare the content of two tar archives?

like image 617
Alex Avatar asked Oct 30 '25 20:10

Alex


1 Answers

The best I can think of is to use:

tar -tvf archive.tar

to list the contents of the file.

Something like:

tar -tvf archive1.tar > list1
tar -tvf archive2.tar > list2
diff list1 list2
like image 101
Nathan Fellman Avatar answered Nov 01 '25 15:11

Nathan Fellman



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!