简体   繁体   English

从tar文件中提取特定目录而不创建包含层次结构

[英]extracting specific dir from tar file without creating the containing hierarchy

Suppose a tar file have the following layout 假设tar文件具有以下布局

$ tar -xvf test.tar -C test ./one/two/three

./one/two/three/
./one/two/three/four/
./one/two/three/four/file00.txt
./one/two/three/four/file01.txt
./one/two/three/four/file02.txt
./one/two/three/four/file03.txt
./one/two/three/four/file04.txt
./one/two/three/four/file05.txt

Is it possible to extract out only dir named " four " and it's content to specified dir. 是否可以仅提取名为“ four ”的目录,并将其内容包含到指定目录中。 But the dir four should be at immediate to the output dir mentioned. 但是,DIR 4应该是一时所提到的输出目录。

$ tar -xvf test.tar -C test one/two/three

I've tried the above but the output dir test is containing all the folder hierarchy to dir four. 我已经尝试了上面的方法,但是输出目录测试包含目录四的所有文件夹层次结构。

您是否考虑过使用tardy预处理tar存档?

这仅适用于提取./one/two/three/four/目录:

tar -xvf test.tar ./one/two/three/four/

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM