Shell-Script

我可以以某種方式更新壓縮檔案嗎?

  • May 15, 2016

我正在嘗試查找具有給定副檔名的所有文件,但出現此錯誤:

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.

這是腳本:

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

有什麼方法可以使用 find 更新壓縮存檔?

不,您不能使用tar.

但是,如果您的腳本正在創建存檔(使用touch),您可以稍後對其進行更新和壓縮。更改rjvfrvf,然後在腳本末尾執行bzip2 archive.tar(我從j選項和您要bzip2用於壓縮的標籤中獲取它)。

引用自:https://unix.stackexchange.com/questions/283139