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 ?

1 Answer 1


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

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

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .