I know how to gunzip
a file to a selected location.
But when it comes to utilizing all CPU power, many consider pigz
instead of gzip
. So, the question is how do I unpigz
(and untar) a *.tar.gz file to a specific directory?
I found three solutions:
With GNU tar
, using the awesome -I
option:
tar -I pigz -xvf /path/to/archive.tar.gz -C /where/to/unpack/it/
With a lot of Linux piping (a "geek way"):
unpigz < /path/to/archive.tar.gz | tar -xvC /where/to/unpack/it/
More portable (to other tar
implementations):
unpigz < /path/to/archive.tar.gz | (cd /where/to/unpack/it/ && tar xvf -)
(You can also replace tar xvf -
with pax -r
to make it POSIX-compliant, though not necessarily more portable on Linux-based systems.)
Credits go to @PSkocik for a proper direction, @Stéphane Chazelas for the 3rd variant and to the author of this answer.
-I
needs to understand the -d
flag for decompression (and pigz
does understand it).
-I
(compression program) to tar might work. If it doesn't, you can decompress to stdin and untar the stdin stream with the-C
switch orcd
to the target directory.