gpt4 book ai didi

bash - 从具有重复条目名称的 tar 文件中提取

转载 作者:行者123 更新时间:2023-11-29 09:06:06 24 4
gpt4 key购买 nike

如果多次将同一个文件添加到一个 tar 文件中,然后提取该文件,是否保证提取的版本与上次添加的版本相同?

~/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

这是有道理的,但我找不到任何相关的文档。我想知道是否有知情人士可能知道,或者是否有人知道情况并非如此?

最佳答案

Some documentation for tar是这样说的:

When you extract a file from the archive, only the version stored lastwill wind up in the file system. Because '--extract' ('-x') extractsfiles from an archive in sequence, and overwrites files with the samename in the file system, if a file name appears more than once in anarchive the last version of the file will overwrite the previousversions which have just been extracted. You should avoid storingolder versions of a file later in the archive.

我的理解是,除非您使用 --keep-old-files 选项,否则 -x 将始终覆盖存档中存储的最后一个文件。

编辑:另见 GNU documentation for tar .

关于bash - 从具有重复条目名称的 tar 文件中提取,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33376066/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com