【发布时间】:2010-05-13 02:08:34
【问题描述】:
我只想提取 tar 文件文件夹中的文件
例子:
tar 文件内容:
/home/parent_dir/child_dir/
我只想将 child_dir 中的文件提取到另一个目录
【问题讨论】:
我只想提取 tar 文件文件夹中的文件
例子:
tar 文件内容:
/home/parent_dir/child_dir/我只想将 child_dir 中的文件提取到另一个目录
【问题讨论】:
命令
tar xf tarfile.tar /home/parent_dir/child_dir
只会提取child_dir及其下属中的文件。
如果 /home/parent_dir/child_dir 不是您希望它们出现的位置,GNU tar 提供了一个 --transform 选项,其用法如下:
tar --transform 's,/home/parent_dir/child_dir,foo,' --show-transformed -xf tarfile.tar
这会将原本进入/home/parent_dir/child_dir 的文件放入./foo。
【讨论】:
cd <another_directory>tar xvf <path_to_tar>/<tarfile>.tar <child_dir>
例如cd <parent_directory>tar cvf test.tar *tar tf test.tar
查看您想要的文件夹。例如src/orgcd <some other directory you want to extract to>tar xvf ..\test.tar src/orgls
您现在将看到您从 tar 获取的目录,例如src/org
【讨论】: