discussed creating and unpacking compressed tar
This article explains how to simplify those two-step processes.
The first command line below creates a gzip
the second extracts it:
tar cf -
| gzip > archive.tar.gz
gzcat archive.tar.gz | tar xf -
uncompresses a file (the gzip
well as older compress
formats), sending the result to
standard output. With the f
listed as a filename, tar
writes to standard output when
creating an archive and reads from standard input when extracting.
You don't need to create the larger, uncompressed file; you can
store the archive permanently in its compressed form.
To extract only some of the files in the archive, give the
on the command line exactly
as they're stored in
will extract all the files.
(For a list of the exact pathnames, use
tar tf -
makes this even easier.
shows, the GNU z
option creates or extracts a gzip
Here are the two examples above using the z
tar czf archive.tar.gz
tar xzf archive.tar.gz
, you can use
will list each file as it's processed.
If you extract files from an archive that you didn't create, the
files you extract may not belong to you.
On many non-BSD systems, when tar
extracts a file,
the file will be owned by the same
that owned the file when the archive was created.
If that UID isn't yours, tar
may extract directories
you can't modify and files you can't edit.
On systems with that problem, you can add the o
) to be sure that files
extracted will belong to you.