Hello,
I want to extract only the files inside a folder of a tar file
Example:
Contents of tar file: /home/parent_dir/child_dir/
I want to extract only the files inside child_dir to another directory
Thanks, SB
Hello,
I want to extract only the files inside a folder of a tar file
Example:
Contents of tar file: /home/parent_dir/child_dir/
I want to extract only the files inside child_dir to another directory
Thanks, SB
cd <another_directory>
tar xvf <path_to_tar>/<tarfile>.tar <child_dir>
e.g.
cd <parent_directory>
tar cvf test.tar *
tar tf test.tar
see the folder you wanted. e.g.src/org
cd <some other directory you want to extract to>
tar xvf ..\test.tar src/org
ls
you'll now see the directory you were after from the tar e.g.src/org
The command
tar xf tarfile.tar /home/parent_dir/child_dir
will only extract files in child_dir
and its subordinates.
If /home/parent_dir/child_dir
is not where you want them to be, GNU tar provides a --transform
option that would be used like:
tar --transform 's,/home/parent_dir/child_dir,foo,' --show-transformed -xf tarfile.tar
which will put the files that would have gone into /home/parent_dir/child_dir
into ./foo
instead.