Mac OS X Unleashed

Mac OS X Unleashed

By John Ray and William C. Ray

gzip, gunzip, zcat

gzip  
gunzip  
zcat Compresses or expands files.
gzip [-acdfhlLnNrtvV19] [-S <suffix>] <file1> <file2> …
gunzip [-acfhlLnNrtvV] [-S <suffix>] <file1><file2> …
zcat [-fhLV] <file1> 
               <file2>
gzip reduces the size of a file and renames the file by adding the .gz extension. It keeps the same ownership modes, and access and modification times. If no files are specified, or if the filename - is specified, standard input is compressed to standard output. gzip compresses regular files, but ignores symbolic links.
Compressed files can be restored to their original form by using gunzip, gzip -d, or zcat.
gunzip takes a list of files from the command line, whose names end in .gz, -gz, .z, -z, _z, or .Z, and which also begin with the correct magic number, and replaces them with expanded files without the original extension. gunzip also recognizes the extensions .tgz and .taz as short versions of .tar.gz and .tar.Z, respectively. If necessary, gzip uses the .tgz extension to compress a .tar file.
zcat is equivalent to gunzip -c. It uncompresses either a list of files on the command line or from standard input and writes uncompressed data to standard output. zcat uncompresses files that have the right magic number, whether or not they end in .gz.
Compression is always formed, even if the compressed file is slightly larger than the original file.
-a ASCII text mode. Converts end-of-lines using local conventions. Supported only on some non-Unix systems.
—ascii Same as -a.
-c Writes output to standard output and keeps the original files unchanged.
—stdout Same as -c.
—to-stdout Same as -c.
-d Decompresses.
—decompress Same as -d.
—uncompress Same as -d.
-f Forces compression or decompression, even if the file has multiples links or if the corresponding file already exists, or if the compressed data is read from or written to a terminal. If -f is not used, and gzip is not working in the background, the user is prompted before a file is overwritten.
-h Displays a help screen and quits.
—help Same as -h.
-l

Lists the following fields for each compressed file:

compressed (compressed size)

uncompressed (uncompressed size)

ratio (compression ratio; 0.0% if unknown)

uncompressed_name (name of uncompressed file)

Uncompressed size is -1 for files not in gzip format. To get an uncompressed size for such files, use

zcat <file1.Z> | wc -c

Combined with -verbose, it also displays method (compression method)

crc (32-bit CRC of the uncompressed data)

date and time (time stamp of the uncompressed file)

Compression methods supported are deflate, compress, lzh, and pack. crc is listed as ffffffff when the file is not in gzip format.

—list Same as -l.
-L Displays the gzip license and quits.
—license Same as -L
-n

When compressing, does not save the original filename and time stamp by default. (Always saves the original name if it has to be truncated.)

When decompressing, it does not restore the original name (only removes .gz) and time stamp (only copies it from compressed file), if present. This is the default.

—no-name Same as -n.
-N

When compressing, always saves the original filename and time stamp. This is the default.

When decompressing, it restores the original time stamp and filename if present.

—name Same as -N.
-q Suppresses all warnings.
—quiet Same as -q.
-r

Traverses the directory structure recursively.

If a filename specified on the command line is a directory, gzip/gunzip descends into the directory and compresses/decompresses the files in that directory.

—recursive Same as -r.
-S <suffix>

Uses <suffix> instead of .gz. Any suffix can be used, but it is recommended that suffixes other than .z or .gz be avoided to avoid confusion when transferring them to other systems.

A null suffix (-S "") forces gunzip to try decompression on all listed files, regardless of suffix.

—suffix <suffix> Same as -S <suffix>.
-t Test. Checks the integrity of the compressed file.
—test Same as —test.
-v Verbose. Displays the name and percentage reduction for each file compressed or decompressed.
—verbose Same as -v.
-V Version. Displays the version number and compilation options and quits.
—version Same as -V.
-<n>  
—fast  
—best Regulates the speed of compression as specified by -<n>, where -1 (or —fast) is the fastest compression method (least compression) and -9 (or —best) is the slowest compression method (most compression). Default compression option is -6.

+ Share This