If you add the same file to a tar file multiple times, and then extract that file, are you guaranteed that the extracted version is equivalent to the one which was last added?
~/tmp> echo hi > foo
~/tmp> tar -cf bar.tar foo
~/tmp> echo bye > foo
~/tmp> tar -uf bar.tar foo
~/tmp> tar -tf bar.tar
foo
foo
~/tmp> rm foo
~/tmp> tar -xf bar.tar foo
~/tmp> cat foo
bye
It make sense that it would, but I can't find any documentation to that effect. I'm wondering if anyone in the know might know, or if someone knows a circumstance where this is not true?
To extract (unzip) a tar.gz file simply right-click on the file you want to extract and select “Extract”. Windows users will need a tool named 7zip to extract tar.gz files. The -v option will make the tar command more visible and print the names of the files being extracted on the terminal.
With the tar command, you can use -t to view the contents of tar. gz files with the list of details. The -t switch is used to list the contents of the tar. gz file without actually extracting it.
Some documentation for tar says this:
When you extract a file from the archive, only the version stored last will wind up in the file system. Because '--extract' ('-x') extracts files from an archive in sequence, and overwrites files with the same name in the file system, if a file name appears more than once in an archive the last version of the file will overwrite the previous versions which have just been extracted. You should avoid storing older versions of a file later in the archive.
My understanding is that, unless you use the --keep-old-files
option, -x
will always overwrite with the last file stored in the archive.
Edit: see also the GNU documentation for tar
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With