How do I compare two tar archives (including file contents, new/deleted files, symbolic links)?… here is a solution to the problem.
How do I compare two tar archives (including file contents, new/deleted files, symbolic links)?
I
have two tar files (compressed or uncompressed) and I want to find out all the differences in these two files. Both files contain a complete file system (i.e., after extraction, directories such as /bin, /home
, /root, /usr
, /var,
/etc
,… I hope you understand). I would like a list with the following:
- New file
- Deleted files
- Change the file (file contents, not just size).
- Change symbolic links (relative and absolute).
- New/deleted symbolic links
I can’t just unzip these files and use diff because diff
doesn’t recognize absolute symbolic links correctly (because they point out the filesystem structure of the file).
Is there any other way to compare the contents of two tar archives?
Solution
The best way I can think of is to use:
tar -tvf archive.tar
Lists the contents of the file.
Similar to:
tar -tvf archive1.tar > list1
tar -tvf archive2.tar > list2
diff list1 list2