How can I uncompress and unarchive a .tar.gz file using cat, tar and gzip on one command line? Is this even possible?
closed as unclear what you're asking by Jeff Schaller, John WH Smith, G-Man, mdpc, countermode Jan 13 '17 at 8:04
Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.
No need for
$ tar xvzf archive.tar.gz
The option string tells
tar to extract (
x) in verbose mode (
v) the compressed (
z) archive following the
Using all of
gzip (which is silly, don't do this):
$ cat archive.tar.gz | gzip -d -c | tar xvf -
$ gzip -d -c archive.tar.gz | cat | tar xvf -
- as the filename,
tar will read the archive from standard input.
The last two examples suffer from what's commonly called "Useless use of
cat", since the only thing
cat does is to shuffle data to the next part of the pipeline.
A slightly better version, without the
$ gzip -c -d archive.tar.gz | tar xvf -
This may actually be a useful thing to know how to do on a system where
tar doesn't know how to handle compressed archives.
The archaic option string that I've used for
tar above, without the dash (
-) in front of it, comes from a time before the dash was commonly used for specifying command line options. Other utilities that do not use regular option syntax includes
mt, but whereas most implementations of
tar today understands the newer dash options,
dd usually doesn't. The
mt command (which controls magnetic tape operations) has acquired some dash options (especially on Linux), but the only non-optional part of the command line is still the command that you'd like to perform on the drive, such as