这个关于 Linux 的 zip 实用程序的网站对-u
标志说:
仅当 zip 存档中的现有条目的修改时间比 zip 存档中已有的版本更新时,才替换(更新)该条目。例如:
Run Code Online (Sandbox Code Playgroud)zip -u stuff * will add any new files in the current directory, and update any files which
自上次创建/修改 zip 存档 stuff.zip 以来已被修改。
我的问题是,如果某个特定文件自上次压缩后-u
已被删除,是否会识别出该文件已被删除,从而将其从 *.zip 文件中删除?或者,缺少时间戳信息(因为文件现在已被删除),它会将备份文件保留在 *.zip 中,因为没有“更新”的文件?
Dra*_*oan 10
在 zip 版本 3.0 上有:
The new File Sync option (-FS) is also considered a new mode, though it
is similar to update. This mode synchronizes the archive with the
files on the OS, only replacing files in the archive if the file time
or size of the OS file is different, adding new files, and deleting
entries from the archive where there is no matching file. As this mode
can delete entries from the archive, consider making a backup copy of
the archive.
Run Code Online (Sandbox Code Playgroud)
我认为这就是你所追求的?
如果您确实想将文件保留在存档中,请-u
执行以下操作:
$ mkdir test && touch test/{flibble,foobaz,blurp}
$ zip -r test test
adding: test/ (stored 0%)
adding: test/foobaz (stored 0%)
adding: test/flibble (stored 0%)
adding: test/blurp (stored 0%)
$ rm test/flibble && touch test/{,flibble}
$ zip -ru test test
updating: test/ (stored 0%)
updating: test/flibble (stored 0%)
$ unzip -l test
Archive: test.zip
Length Date Time Name
--------- ---------- ----- ----
0 2013-08-15 22:04 test/
0 2013-08-15 22:04 test/foobaz
0 2013-08-15 22:04 test/flibble
0 2013-08-15 22:04 test/blurp
--------- -------
0 4 files
Run Code Online (Sandbox Code Playgroud)