Answer the question
In order to leave comments, you need to log in
How to extract a separate subfolder from an archive without saving the full path to it?
Let's say there is an archive with the following content:
arc.tar.gz
--one
----two
------someFile.txt
You need to extract the two folder to the current directory.
I try this: tar -xzvf arc.tar.gz one/two
Result - the folder is extracted but with the preservation of the directory structure, that is, one / two.
How can I extract just folder two?
Answer the question
In order to leave comments, you need to log in
GNU tar has a --strip=N magic option that strips N directory levels from the path root:
https://superuser.com/a/377247
https://www.gnu.org/software/tar/manual/tar. html#SEC114
And there is also a magic --xform option that allows you to rewrite paths with regexp!
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question