Tar --files-from 加倍文件结果

Tar --files-from doubling files in result

当 tar 使用 --files-from 访问包含超过 10K 个图像文件和 CSV 文件的目录时,我最终得到了两倍的所有内容。我对 tar 不是很熟悉,希望得到一些帮助。

目前,我是 运行 来自 PHP 脚本的 exec 命令。生成的文件的位置正在按我想要的方式工作。但是,不能让它只包含 tar.gz 文件中的一份文件副本。下面的代码是我目前运行。

// the archiveExportPath includes a directory path to the location where the tar.gz file will be stored.
exec("cd {$this->tmpDirectory} && find -name '*.*' -print >../export.manifest");
exec("cd {$this->tmpDirectory} && sudo tar -czf {$this->archiveExportPath} --files-from ../export.manifest");

我希望看到的只是在 tar.gz

中包含一份 .jpg 文件和 .csv 文件

我找到了解决办法。更改命令以搜索特定文件就可以了。

exec("cd $tmpDir && find . \( -name '*.jpg' -o -name '*.csv' \)  -print >../export.manifest");