11

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?

2
  • superuser.com/questions/348205/… Commented Apr 27, 2015 at 19:25
  • 1
    The -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 or cd to the target directory. Commented Apr 27, 2015 at 19:28

1 Answer 1

17

I found three solutions:

  1. With GNU tar, using the awesome -I option:

    tar -I pigz -xvf /path/to/archive.tar.gz -C /where/to/unpack/it/
    
  2. With a lot of Linux piping (a "geek way"):

    unpigz < /path/to/archive.tar.gz | tar -xvC /where/to/unpack/it/
    
  3. 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.

2
  • As far as I can see, "tar -I" only works as a compression option. Also, pigz will only use a maximum of 2 cores while decompressing - it's not a parallel operation.
    – Simon B
    Commented Jun 16, 2021 at 8:50
  • It does work, the command passed to -I needs to understand the -d flag for decompression (and pigz does understand it).
    – ferada
    Commented Jul 5 at 9:48

You must log in to answer this question.

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