I have a huge gzipped tar archive file huge.tar.gz
from which I want to extract a subset and put it in a new gzipped tar file archive subset.tar.gz
, without first extracting all of the huge file. For example if listing the content of huge.tar.gz
:
tar tfz huge.tar.gz
dir1/bla/bla.bla
dir2/bla/bla.bla
dir3/bla/bla.bla
, how can I create a new tar archive file subset.tar.gz
containing only dir1:
tar tfz subset.tar.gz
dir1/bla/bla.bla
This is a two-step process. First you need to extract the directory from the tarball:
tar -zxf huge.tar.gz dir1
And then you need to compress it:
tar -zcf subset.tar.gz dir1