How can I extract a specific directory in a local directory ? For instance,

$ mkdir project
$ ll
-rwxrwxrwx 1 root root 343535  8월 17 08:56 foo.tar.gz*
drwxrwxrwx 2 root root      0  8월 17 09:04 project/

foo.tar.gz's root is a directory containing all the files I want to extract in project

I tried

tar -C project -xzvf foo.tar.gz root_dir/

no luck...

$ ls project

Again, I need root_dir's content in this example to be in project directory. How can I do that ?


my bad, the answer was just under my nose..

tar -C project/ --strip-components=1 -xzvf foo.tar.gz root_dir

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.