我可以以某种方式更新压缩档案吗?

pno*_*nom 4 tar shell-script bzip2

我正在尝试查找具有给定扩展名的所有文件,但出现此错误:

tar: Cannot update compressed archives
Try 'tar --help' or 'tar --usage' for more information.
tar: Cannot update compressed archives
Try 'tar --help' or 'tar --usage' for more information.
tar: Cannot update compressed archives
Try 'tar --help' or 'tar --usage' for more information.
tar: Cannot update compressed archives
Try 'tar --help' or 'tar --usage' for more information.
tar: Cannot update compressed archives
Try 'tar --help' or 'tar --usage' for more information.
tar: Cannot update compressed archives
Try 'tar --help' or 'tar --usage' for more information.
Run Code Online (Sandbox Code Playgroud)

这是脚本:

touch archive.tar.bz2; find . -type f \( -name '*.bak' -o -name '*.c' -o -name '~*' \) -exec tar rjvf archive.tar.bz2 {} \; -exec rm -rf {} \;
Run Code Online (Sandbox Code Playgroud)

有什么方法可以使用find更新压缩档案吗?

Ste*_*itt 5

不,您不能使用tar.

但是,如果您的脚本正在创建存档(使用touch),您可以稍后更新并压缩它。更改rjvfrvf,并在脚本结束时运行bzip2 archive.tar(我从j选项和要bzip2用于压缩的标签中获取它)。