Extract from tar file with double entry names

If you add the same file to the tar file several times and then extract the file, is it guaranteed that the extracted version is equivalent to the last one 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 makes sense that this will be, but I can not find any documentation on this subject. I am wondering if any of the acquaintances know, or if someone knows the circumstances when this is not so?

+5
source share
1 answer

Some documentation for tar says this:

When you extract a file from the archive, only the latest saved version will appear on the file system. Since `--extract '(' -x ') extracts files from the archive sequentially and overwrites files with the same name in the file system, if the file name appears more than once in the archive, the latest version of the file will overwrite previous versions that have just been extracted. You should avoid storing older versions of the file later in the archive.

-k I understand that if you do not use -k , -x will always overwrite the last file stored in the archive.

Change: see also GNU documentation for tar .

+2
source

Source: https://habr.com/ru/post/1234628/


All Articles