【发布时间】:2011-09-30 19:23:29
【问题描述】:
示例设置:文件夹结构
/folder1/folder2/folder3
文件夹 3 有 2 个文件:
sample.backups.tarsample
我的目标是运行一个 bzips 示例并将其附加到 sample.backups.tar 的脚本,删除 bzip 之外的压缩文件。
我写了以下几行
folder3Path=#full path for folder3
samplePath=#full path with file name for sample file
compressedSamplePath=#full path with file name for bzipped sample file to be created
sampleBackupsPath=#full path with file name for sample.backups.tar
tar -jcf $compressedPath sample
tar -r --file=$sampleBackupsPath $compressedSamplePath --remove-files
结果是在 sample.backups.tar 我有文件结构 /folder1/folder2/folder3/sample.tar.bz2。
我不想要那里的文件夹结构;我只希望 sample.tar.bz2 出现在该文件中,而没有文件夹。我将如何做到这一点?
尝试过的事情:
tar -jcf $compressedPath sample
tar -C $folder3Path -r --file=$sampleBackupsPath $compressedSamplePath --remove-file
尝试将文件夹更改为压缩示例文件,但它仍然给了我文件夹结构
注意:
对于我的要求,我需要对所有名称引用使用绝对路径和完整路径。 我正在使用 tar 的附加模式,因为我需要使用同一个 tar 来存储多个 bzip。
【问题讨论】:
标签: bash compression tar