The obvious way to extract a tar.gz archive is using the following two commands:
sharfah@starship:~> gunzip foo.tar.gz
sharfah@starship:~> tar xvf foo.tar
This is how you can achieve the same thing, but in a single command:
sharfah@starship:~> gunzip -c foo.tar.gz | tar xvf -
or alternatively:
sharfah@starship:~> gunzip < foo.tar.gz | tar xvf -
Both commands write the data produced from the gunzip command to standard out (-c in the first example and using < in the second). The output is then piped into the tar command. The "-" represents standard input.
Creating a tar.gz:
A tar.gz file is normally created using two commands as follows:
sharfah@starship:~> tar cvf foo.tar foodir
sharfah@starship:~> gzip foo.tar
Again, there is a single command to do the same thing:
sharfah@starship:~> tar cvf - foodir | gzip > foo.tar.gz
What about
ReplyDeletetar xvzf archive.tar.gz
and
tar cvzf archive.tar.gz files ...
On (K)Ubuntu I get away with simply:
ReplyDeletetar xfs archive.tar.gz