gunzip - Unix, Linux Command



NAME

gunzip, gzip - compress or expand files

SYNOPSIS

gunzip [ -acfhlLnNrtvV ] [-S suffix] [ name ... ]
gzip [ -acdfhlLnNrtvV19 ] [-S suffix] [ name ... ]

DESCRIPTION

gunzip takes a list of files on its command line and replaces each file whose name ends with .gz, -gz, .z, -z, _z or .Z and which begins with the correct magic number with an uncompressed file without the original extension. gunzip also recognizes the special extensions .tgz and .taz as shorthands for .tar.gz and .tar.Z respectively. When compressing, gzip uses the .tgz extension if necessary instead of truncating a file with a .tar extension.

gunzip can currently decompress files created by gzip, zip, compress, compress -H or pack. The detection of the input format is automatic. When using the first two formats, gunzip checks a 32 bit CRC. For pack, gunzip checks the uncompressed length. The standard compress format was not designed to allow consistency checks. However gunzip is sometimes able to detect a bad .Z file. If you get an error when uncompressing a .Z file, do not assume that the .Z file is correct simply because the standard uncompress does not complain. This generally means that the standard uncompress does not check its input, and happily generates garbage output. The SCO compress -H format (lzh compression method) does not include a CRC but also allows some consistency checks.

Files created by zip can be uncompressed by gzip only if they have a single member compressed with the 'deflation' method. This feature is only intended to help conversion of tar.zip files to the tar.gz format. To extract a zip file with a single member, use a command like gunzip <foo.zip or gunzip -S .zip foo.zip. To extract zip files with several members, use unzip instead of gunzip.

Options

Tag Description
-a, --ascii ASCII text mode: convert end-of-lines using local conventions. This option is supported only on some non-Unix systems. For MSDOS, CR LF is converted to LF when compressing, and LF is converted to CR LF when decompressing.
-c, --stdout, --to-stdout Write output on standard output; keep original files unchanged. If there are several input files, the output consists of a sequence of independently compressed members. To obtain better compression, concatenate all input files before compressing them.
-d, --decompress, --uncompress Decompress.
-f, --force Force compression or decompression even if the file has multiple links or the corresponding file already exists, or if the compressed data is read from or written to a terminal. If the input data is not in a format recognized by gzip, and if the option --stdout is also given, copy the input data without change to the standard output: let zcat behave as cat. If -f is not given, and when not running in the background, gzip prompts to verify whether an existing file should be overwritten.
-h, --help Display a help screen and quit.
-L, --license Display the gzip license and exit.
-n, --no-name When compressing, do not save the original file name and timestamp by default. (The original name is always saved if the name had to be truncated.) When decompressing, do not restore the original file name if present (remove only the gzip suffix from the compressed file name) and do not restore the original time stamp if present (copy it from the compressed file). This option is the default when decompressing.
-N, --name When compressing, always save the original file name and time stamp; this is the default. When decompressing, restore the original file name and time stamp if present. This option is useful on systems which have a limit on file name length or when the time stamp has been lost after a file transfer.
-q, --quiet Suppress all warnings.
-r, --recursive Travel the directory structure recursively. If any of the file names specified on the command line are directories, gzip will descend into the directory and compress all the files it finds there (or decompress them in the case of gunzip).
-S .suf, --suffix .suf When compressing, use suffix .suf instead of .gz. Any non-empty suffix can be given, but suffixes other 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 output file name from an input file name.
-t, --test Test. Check the compressed file integrity.
-v, --verbose Verbose. Display the name and percentage reduction for each file compressed or decompressed.
-V, --version Version. Display the version number and compilation options then quit.
-#, --fast, --best Regulate the speed of compression using the specified digit #, where -1 or --fast indicates the fastest compression method (less compression) and -9 or --best indicates the slowest compression method (best compression). The default compression level is -6 (that is, biased towards high compression at expense of speed).

EXAMPLES

Example-1:

To Decompress A File Using The "gunzip" Command:

$ gunzip myfilename.gz

output:

$ ls
myfilename.gz

$ gunzip myfilename.gz

$ ls
myfilename

Example-2:

Force A File To Decompress:

$ gunzip -f myfilename.gz

output:

$ ls
myfilename.gz

$ gunzip myfilename.gz

$ ls
myfilename

Example-3:

To keep both the compressed and decompressed file:

$ gunzip -k myfile.gz

output:

$ ls
myfilename.gz

$ gunzip -k myfilename.gz

$ ls
myfilename  myfilename.gz

Example-4:

To display compressed output:

$ gunzip -l myfile.gz

output:

$ gunzip -l myfilename.gz
         compressed        uncompressed  ratio uncompressed_name
                 31                   0   0.0% myfilename

Example-5:

Decompressing Lots Of Files Recursively:

$ gunzip -r /tmp

output:

$ ls /tmp/
myfilename1.gz  myfilename.gz

$ gunzip -r /tmp/

$ ls /tmp/
myfilename  myfilename1

Print
Advertisements