当使用--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");