Linux "zcat" Command Line Options and Examples
compress or expand files

Gzip reduces the size of the named files using Lempel-Ziv coding (LZ77). Whenever possible, each file is replaced by one with the extension .gz, while keeping the same ownership modes, access and modification times.


Usage:

gzip [ -acdfhklLnNrtvV19 ] [--rsyncable] [-S suffix] [ name ... ]
    gunzip [ -acfhklLnNrtvV ] [-S suffix] [ name ... ]
    zcat [ -fhLV ] [ name ... ]






Command Line Options:

-a
Ascii text mode: convert end-of-lines using local conventions. This option is supported only on somenon-Unix systems. For MSDOS, CR LF is converted to LF when compressing, and LF is converted to CR LFwhen decompressing.
zcat -a ...
-c
Write output on standard output; keep original files unchanged. If there are several input files, theoutput consists of a sequence of independently compressed members. To obtain better compression, con‐catenate all input files before compressing them.
zcat -c ...
-f
Force compression or decompression even if the file has multiple links or the corresponding filealready exists, or if the compressed data is read from or written to a terminal. If the input data isnot in a format recognized by gzip, and if the option --stdout is also given, copy the input data with‐out change to the standard output: let zcat behave as cat. If -f is not given, and when not running inthe background, gzip prompts to verify whether an existing file should be overwritten.
zcat -f ...
-h
Display a help screen and quit.
zcat -h ...
-k
Keep (don't delete) input files during compression or decompression.
zcat -k ...
-l
For each compressed file, list the following fields:compressed size: size of the compressed fileuncompressed size: size of the uncompressed fileratio: compression ratio (0.0% if unknown)uncompressed_name: name of the uncompressed fileThe uncompressed size is given as -1 for files not in gzip format, such as compressed .Z files. To getthe uncompressed size for such a file, you can use:zcat file.Z | wc -cIn combination with the --verbose option, the following fields are also displayed:method: compression methodcrc: the 32-bit CRC of the uncompressed datadate & time: time stamp for the uncompressed fileThe compression methods currently supported are deflate, compress, lzh (SCO compress -H) and pack. Thecrc is given as ffffffff for a file not in gzip format.With --name, the uncompressed name, date and time are those stored within the compress file ifpresent.With --verbose, the size totals and compression ratio for all files is also displayed, unless somesizes are unknown. With --quiet, the title and totals lines are not displayed.
zcat -l ...
-L
Display the gzip license and quit.
zcat -L ...
-n
When compressing, do not save the original file name and time stamp by default. (The original name isalways saved if the name had to be truncated.) When decompressing, do not restore the original filename if present (remove only the gzip suffix from the compressed file name) and do not restore theoriginal time stamp if present (copy it from the compressed file). This option is the default whendecompressing.
zcat -n ...
-N
When compressing, always save the original file name and time stamp; this is the default. When decom‐pressing, restore the original file name and time stamp if present. This option is useful on systemswhich have a limit on file name length or when the time stamp has been lost after a file transfer.
zcat -N ...
-q
Suppress all warnings.
zcat -q ...
-r
Travel the directory structure recursively. If any of the file names specified on the command line aredirectories, gzip will descend into the directory and compress all the files it finds there (or decom‐press them in the case of gunzip ).
zcat -r ...
--rsyncable
While compressing, synchronize the output occasionally based on the input. This increases size by lessthan 1 percent most cases, but means that the rsync(1) program can take advantage of similarities inthe uncompressed input when synchronizing two files compressed with this flag. gunzip cannot tell thedifference between a compressed file created with this option, and one created without it.
zcat --rsyncable ...
-S
When compressing, use suffix .suf instead of .gz. Any non-empty suffix can be given, but suffixesother than .z and .gz should be avoided to avoid confusion when files are transferred to other systems.When decompressing, add .suf to the beginning of the list of suffixes to try, when deriving an outputfile name from an input file name.
zcat -S ...
-t
Test. Check the compressed file integrity.
zcat -t ...
-v
Verbose. Display the name and percentage reduction for each file compressed or decompressed.
zcat -v ...
-V
Version. Display the version number and compilation options then quit.
zcat -V ...
-#
Regulate the speed of compression using the specified digit #, where -1 or --fast indicates the fastestcompression method (less compression) and -9 or --best indicates the slowest compression method (bestcompression). The default compression level is -6 (that is, biased towards high compression at expenseof speed).ADVANCED USAGEMultiple compressed files can be concatenated. In this case, gunzip will extract all members at once. Forexample:gzip -c file1 > foo.gzgzip -c file2 >> foo.gzThengunzip -c foois equivalent tocat file1 file2In case of damage to one member of a .gz file, other members can still be recovered (if the damaged member isremoved). However, you can get better compression by compressing all members at once:cat file1 file2 | gzip > foo.gzcompresses better thangzip -c file1 file2 > foo.gzIf you want to recompress concatenated files to get better compression, do:gzip -cd old.gz | gzip > new.gzIf a compressed file consists of several members, the uncompressed size and CRC reported by the --list optionapplies to the last member only. If you need the uncompressed size for all members, you can use:gzip -cd file.gz | wc -cIf you wish to create a single archive file with multiple members so that members can later be extracted inde‐pendently, use an archiver such as tar or zip. GNU tar supports the -z option to invoke gzip transparently.gzip is designed as a complement to tar, not as a replacement.ENVIRONMENTThe environment variable GZIP can hold a set of default options for gzip. These options are interpreted firstand can be overwritten by explicit command line parameters. For example:for sh: GZIP="-8v --name"; export GZIPfor csh: setenv GZIP "-8v --name"for MSDOS: set GZIP=-8v --nameOn Vax/VMS, the name of the environment variable is GZIP_OPT, to avoid a conflict with the symbol set forinvocation of the program.
zcat -# ...