Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Say I have unpacked a gz-compressed tar file, and do not remember what changes I made to the unpacked files, or I archived a folder a while ago and want to know what has changed to the files since.

I can use tar -zd to get an overview. Then, say it shows me file foo has changed. How can I see the changes in this file, i.e. the difference between the file on my file system and the (older) file in the archive (ideally in vimdiff, but diff output would be fine too)?

share|improve this question
add comment

2 Answers

up vote 0 down vote accepted

Open the compressed tar file in vim, move the cursor to foo and hit Enter. Then execute

:vert diffsplit local/path/to/foo
share|improve this answer
add comment

Use tar ... -O along with process substitution in bash.

diff ... <( tar ... -O ... file.ext ) file.ext
share|improve this answer
    
obtaining a diff with one command line is also nice; after some playing around (not sure how/why it works) diff <(tar -xzOf archive.tgz dir/file.ext) dir/file.ext gave me the correct result –  Kyss Tao Apr 2 '12 at 17:17
    
(correction: I think I do understand it, <( ... ) transforms the stdout of ... into a file) –  Kyss Tao Apr 2 '12 at 17:33
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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