|
It is frequently useful to archive files that have not been used for a
while and then compress them so they take up less disk space. Any
file, including those archives created with
tar, can be compressed.
Compression is a valuable tool since it reduces the amount of disk
space files occupy while still keeping them readily available. The
compress command is used to compress files and is included with all
versions of the UNIX operating system. The compress utility uses a
special format to reduce the size of the file anywhere from 20 percent
to 80 percent depending on the type of file. If the compress utility
determines that the file cannot be compressed or that there will be no
reduction in file size, the file will remain unchanged.
When files are compressed with the
compress command, the existing
file is replaced using the same name but with a .Z suffix appended.
Note that this is an uppercase letter Z. The Figure shows an
example of the
compress command with the verbose (-v) option. This
will show the name of the input (bin.file) and output file (bin.file.Z)
and the amount of compression achieved. Use the ls -l (list long)
command before compressing a file to see its original size in bytes
and then again afterward to see the compressed size. Multiple files
can be compressed simultaneously and wildcard metacharacters are
supported.
| Command Format: |
| compress option
file1 file2 |
|