Tar

tar: FOLDER: 文件在我們讀取時已更改,但添加了 FOLDER 以排除

  • May 24, 2019

tar 命令失敗並出現錯誤“ tar: artifacts: file changed as we read it ” 儘管我添加了文件夾“artifacts”以排除列表

以下命令在一台機器上執行良好(ubuntu 16.04 和 tar 1.28)但每次在另一台機器上都失敗(ubuntu 18.04 和 tar 1.29)

tar -zcf artifacts/source_code.tar.gz * --exclude=artifacts

我想對目前目錄中的所有文件和文件夾進行 tar,不包括我放置 tarball 的目錄。請注意,此命令正在執行

當我執行該命令時,我收到以下消息:

$ tar -zcf artifacts/source_code.tar.gz . --exclude=artifacts
tar: The following options were used after any non-optional arguments in archive create or update mode.  These options are positional and affect only arguments that follow them.  Please, rearrange them properly.
tar: --exclude ‘artifacts’ has no effect
tar: Exiting with failure status due to previous errors

所以你必須把第--exclude一個:

tar -zcf artifacts/source_code.tar.gz --exclude=artifacts *

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