Unix file compression utilities:
There are two commonly used free file compression utlities that
you will find in wide use on the internet.
tar - tape archive
This utility basically appends a list of files &/or directories into one
flat file. This was commonly used in the early days of Unix when writing large
amounts of information to a tape.
Creating a tape archive:
tar -cf archive.tar myDirectories/
Note - using the "v" flag prints out
extra messages, as verbose mode, though it's not
related to extracting files.
Listing the contents of an archive:
tar -tf archive.tar
It is generally a good idea to preview the contents of
tape archives before unpacking them. This can become a serious problem if you
are currently root, and the archive just happens to jump out of the current
directory, and write over some important system files.
Extracting all files from an archive:
tar -xf archive.tar
To extract just partial pieces from
the archive, supply a file or directory name after
the archive name. You can list as many as desiered
here, separated by spaces.
tar -xf archive.tar filename
gzip - gnu zip
This is a gnu utility that is used to compress/decompress a file. Generally,
if there is a set of files to compress, they will be sent through tar first to
create a single file.
Compress:
gzip archive.tar
Decompress:
gunzip archive.tar.gz
Merged filenames:
Sometimes, you will download files
ending with the extension *.tgz - these are essentially
identical to files ending with *.tar.gz files. You
can gunzip them, and untar them just the same way.
If you're working with a recent version of gnu tar,
you may be able to take a shortcut, as described below.
Merging commands
The "z" flag works with gzip, to either create a tar/gzipped archive:
tar -czvf archive.tgz files/
...or decompress a tar/gzipped archive:
tar -xzvf archive.tgz
tar to a pipe
If you're concerned with filling your
disk during a tar, or with filling a disk cache,
you can also tar to a pipe, which doesn't write the
compressed file to disk, but instead just stores it
temporarily in memory.
tar -cf - ./filename | (cd other-directory; tar -xf -)
$Id: tar-gzip.html,v 1.8 2004/06/07 04:53:38 willn Exp $
|