xref: /freebsd/usr.bin/gzip/gzip.1 (revision f9349d427431eaa5b3bd7e9e7e87725a138facd1)
15c4b64e6SXin LI.\"	$NetBSD: gzip.1,v 1.31 2018/10/26 22:10:15 christos Exp $
29a9ea25fSXin LI.\"
390f528e8SXin LI.\" Copyright (c) 1997, 2003, 2004, 2008, 2009, 2015, 2017 Matthew R. Green
49a9ea25fSXin LI.\" All rights reserved.
59a9ea25fSXin LI.\"
69a9ea25fSXin LI.\" Redistribution and use in source and binary forms, with or without
79a9ea25fSXin LI.\" modification, are permitted provided that the following conditions
89a9ea25fSXin LI.\" are met:
99a9ea25fSXin LI.\" 1. Redistributions of source code must retain the above copyright
109a9ea25fSXin LI.\"    notice, this list of conditions and the following disclaimer.
119a9ea25fSXin LI.\" 2. Redistributions in binary form must reproduce the above copyright
129a9ea25fSXin LI.\"    notice, this list of conditions and the following disclaimer in the
139a9ea25fSXin LI.\"    documentation and/or other materials provided with the distribution.
149a9ea25fSXin LI.\"
159a9ea25fSXin LI.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
169a9ea25fSXin LI.\" IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
179a9ea25fSXin LI.\" OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
189a9ea25fSXin LI.\" IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
199a9ea25fSXin LI.\" INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
209a9ea25fSXin LI.\" BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
219a9ea25fSXin LI.\" LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
229a9ea25fSXin LI.\" AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
239a9ea25fSXin LI.\" OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
249a9ea25fSXin LI.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
259a9ea25fSXin LI.\" SUCH DAMAGE.
269a9ea25fSXin LI.\"
279a9ea25fSXin LI.\" $FreeBSD$
28*f9349d42SDag-Erling Smørgrav.Dd November 2, 2022
299a9ea25fSXin LI.Dt GZIP 1
309a9ea25fSXin LI.Os
319a9ea25fSXin LI.Sh NAME
3290f528e8SXin LI.Nm gzip ,
3390f528e8SXin LI.Nm gunzip ,
3490f528e8SXin LI.Nm zcat
359a9ea25fSXin LI.Nd compression/decompression tool using Lempel-Ziv coding (LZ77)
369a9ea25fSXin LI.Sh SYNOPSIS
379a9ea25fSXin LI.Nm
382a8e7ac9SXin LI.Op Fl cdfhkLlNnqrtVv
399a9ea25fSXin LI.Op Fl S Ar suffix
409a9ea25fSXin LI.Ar file
419a9ea25fSXin LI.Oo
429a9ea25fSXin LI.Ar file Oo ...
439a9ea25fSXin LI.Oc
449a9ea25fSXin LI.Oc
459a9ea25fSXin LI.Nm gunzip
46bca072afSXin LI.Op Fl cfhkLNqrtVv
479a9ea25fSXin LI.Op Fl S Ar suffix
489a9ea25fSXin LI.Ar file
499a9ea25fSXin LI.Oo
509a9ea25fSXin LI.Ar file Oo ...
519a9ea25fSXin LI.Oc
529a9ea25fSXin LI.Oc
539a9ea25fSXin LI.Nm zcat
549a9ea25fSXin LI.Op Fl fhV
559a9ea25fSXin LI.Ar file
569a9ea25fSXin LI.Oo
579a9ea25fSXin LI.Ar file Oo ...
589a9ea25fSXin LI.Oc
599a9ea25fSXin LI.Oc
609a9ea25fSXin LI.Sh DESCRIPTION
619a9ea25fSXin LIThe
629a9ea25fSXin LI.Nm
639a9ea25fSXin LIprogram compresses and decompresses files using Lempel-Ziv coding
649a9ea25fSXin LI(LZ77).
659a9ea25fSXin LIIf no
669a9ea25fSXin LI.Ar files
679a9ea25fSXin LIare specified,
689a9ea25fSXin LI.Nm
699a9ea25fSXin LIwill compress from standard input, or decompress to standard output.
709a9ea25fSXin LIWhen in compression mode, each
719a9ea25fSXin LI.Ar file
729a9ea25fSXin LIwill be replaced with another file with the suffix, set by the
739a9ea25fSXin LI.Fl S Ar suffix
749a9ea25fSXin LIoption, added, if possible.
750889440aSXin LI.Pp
769a9ea25fSXin LIIn decompression mode, each
779a9ea25fSXin LI.Ar file
789a9ea25fSXin LIwill be checked for existence, as will the file with the suffix
799a9ea25fSXin LIadded.
800889440aSXin LIEach
810889440aSXin LI.Ar file
820889440aSXin LIargument must contain a separate complete archive;
830889440aSXin LIwhen multiple
840889440aSXin LI.Ar files
850889440aSXin LIare indicated, each is decompressed in turn.
860889440aSXin LI.Pp
870889440aSXin LIIn the case of
880889440aSXin LI.Nm gzcat
890889440aSXin LIthe resulting data is then concatenated in the manner of
900889440aSXin LI.Xr cat 1 .
919a9ea25fSXin LI.Pp
929a9ea25fSXin LIIf invoked as
939a9ea25fSXin LI.Nm gunzip
949a9ea25fSXin LIthen the
959a9ea25fSXin LI.Fl d
969a9ea25fSXin LIoption is enabled.
979a9ea25fSXin LIIf invoked as
989a9ea25fSXin LI.Nm zcat
999a9ea25fSXin LIor
1009a9ea25fSXin LI.Nm gzcat
1019a9ea25fSXin LIthen both the
1029a9ea25fSXin LI.Fl c
1039a9ea25fSXin LIand
1049a9ea25fSXin LI.Fl d
1059a9ea25fSXin LIoptions are enabled.
1069a9ea25fSXin LI.Pp
1079a9ea25fSXin LIThis version of
1089a9ea25fSXin LI.Nm
1099a9ea25fSXin LIis also capable of decompressing files compressed using
1100eeac589SXin LI.Xr compress 1 ,
1110eeac589SXin LI.Xr bzip2 1 ,
1125c4b64e6SXin LI.Ar lzip ,
113*f9349d42SDag-Erling Smørgrav.Xr zstd 1 ,
1149a9ea25fSXin LIor
1150eeac589SXin LI.Xr xz 1 .
1169a9ea25fSXin LI.Sh OPTIONS
1179a9ea25fSXin LIThe following options are available:
1189a9ea25fSXin LI.Bl -tag -width XXrXXXrecursiveX
11990f528e8SXin LI.It Fl 1 , Fl Fl fast
1209a9ea25fSXin LI.It Fl 2 , 3 , 4 , 5 , 6 , 7 , 8
12190f528e8SXin LI.It Fl 9 , Fl Fl best
1229a9ea25fSXin LIThese options change the compression level used, with the
1239a9ea25fSXin LI.Fl 1
1249a9ea25fSXin LIoption being the fastest, with less compression, and the
1259a9ea25fSXin LI.Fl 9
1269a9ea25fSXin LIoption being the slowest, with optimal compression.
1279a9ea25fSXin LIThe default compression level is 6.
12890f528e8SXin LI.It Fl c , Fl Fl stdout , Fl Fl to-stdout
1299a9ea25fSXin LIThis option specifies that output will go to the standard output
1309a9ea25fSXin LIstream, leaving files intact.
13190f528e8SXin LI.It Fl d , Fl Fl decompress , Fl Fl uncompress
1329a9ea25fSXin LIThis option selects decompression rather than compression.
13390f528e8SXin LI.It Fl f , Fl Fl force
1349a9ea25fSXin LIThis option turns on force mode.
135fc268910SXin LIThis allows files with multiple links, symbolic links to regular files,
136fc268910SXin LIoverwriting of pre-existing files, reading from or writing to a terminal,
137fc268910SXin LIand when combined with the
1389a9ea25fSXin LI.Fl c
1399a9ea25fSXin LIoption, allowing non-compressed data to pass through unchanged.
14090f528e8SXin LI.It Fl h , Fl Fl help
1419a9ea25fSXin LIThis option prints a usage summary and exits.
14290f528e8SXin LI.It Fl k , Fl Fl keep
14390f528e8SXin LIThis option prevents
14490f528e8SXin LI.Nm
14590f528e8SXin LIfrom deleting input files after (de)compression.
1469a9ea25fSXin LI.It Fl L , -license
1479a9ea25fSXin LIThis option prints
1489a9ea25fSXin LI.Nm
1499a9ea25fSXin LIlicense.
15090f528e8SXin LI.It Fl l , Fl Fl list
1519a9ea25fSXin LIThis option displays information about the file's compressed and
1529a9ea25fSXin LIuncompressed size, ratio, uncompressed name.
1539a9ea25fSXin LIWith the
1549a9ea25fSXin LI.Fl v
1559a9ea25fSXin LIoption, it also displays the compression method, CRC, date and time
1569a9ea25fSXin LIembedded in the file.
15790f528e8SXin LI.It Fl N , Fl Fl name
1589a9ea25fSXin LIThis option causes the stored filename in the input file to be used
1599a9ea25fSXin LIas the output file.
16090f528e8SXin LI.It Fl n , Fl Fl no-name
161b47ed83dSXin LIThis option stops the filename and timestamp from being stored in
162b47ed83dSXin LIthe output file.
16390f528e8SXin LI.It Fl q , Fl Fl quiet
1649a9ea25fSXin LIWith this option, no warnings or errors are printed.
16590f528e8SXin LI.It Fl r , Fl Fl recursive
1669a9ea25fSXin LIThis option is used to
1679a9ea25fSXin LI.Nm
1689a9ea25fSXin LIthe files in a directory tree individually, using the
1699a9ea25fSXin LI.Xr fts 3
1709a9ea25fSXin LIlibrary.
17190f528e8SXin LI.It Fl S Ar suffix , Fl Fl suffix Ar suffix
1729a9ea25fSXin LIThis option changes the default suffix from .gz to
1739a9ea25fSXin LI.Ar suffix .
17490f528e8SXin LI.It Fl t , Fl Fl test
1759a9ea25fSXin LIThis option will test compressed files for integrity.
17690f528e8SXin LI.It Fl V , Fl Fl version
1779a9ea25fSXin LIThis option prints the version of the
1789a9ea25fSXin LI.Nm
1799a9ea25fSXin LIprogram.
18090f528e8SXin LI.It Fl v , Fl Fl verbose
1819a9ea25fSXin LIThis option turns on verbose mode, which prints the compression
1829a9ea25fSXin LIratio for each file compressed.
1839a9ea25fSXin LI.El
1849a9ea25fSXin LI.Sh ENVIRONMENT
1859a9ea25fSXin LIIf the environment variable
1869a9ea25fSXin LI.Ev GZIP
1879a9ea25fSXin LIis set, it is parsed as a white-space separated list of options
1889a9ea25fSXin LIhandled before any options on the command line.
1899a9ea25fSXin LIOptions on the command line will override anything in
1909a9ea25fSXin LI.Ev GZIP .
191354ed042SXin LI.Sh EXIT STATUS
192354ed042SXin LIThe
193354ed042SXin LI.Nm
194354ed042SXin LIutility exits 0 on success,
195354ed042SXin LI1 on errors,
196354ed042SXin LIand 2 if a warning occurs.
19790f528e8SXin LI.Sh SIGNALS
19890f528e8SXin LI.Nm
19990f528e8SXin LIresponds to the following signals:
20090f528e8SXin LI.Bl -tag -width indent
20190f528e8SXin LI.It Dv SIGINFO
20290f528e8SXin LIReport progress to standard error.
20390f528e8SXin LI.El
2049a9ea25fSXin LI.Sh SEE ALSO
2059a9ea25fSXin LI.Xr bzip2 1 ,
2069a9ea25fSXin LI.Xr compress 1 ,
207*f9349d42SDag-Erling Smørgrav.Xr zstd 1 ,
208140c037aSXin LI.Xr xz 1 ,
2099a9ea25fSXin LI.Xr fts 3 ,
2109a9ea25fSXin LI.Xr zlib 3
2119a9ea25fSXin LI.Sh HISTORY
2129a9ea25fSXin LIThe
2139a9ea25fSXin LI.Nm
2149a9ea25fSXin LIprogram was originally written by Jean-loup Gailly, licensed under
2159a9ea25fSXin LIthe GNU Public Licence.
2169a9ea25fSXin LIMatthew R. Green wrote a simple front end for
2179a9ea25fSXin LI.Nx 1.3
2189a9ea25fSXin LIdistribution media, based on the freely re-distributable zlib library.
2199a9ea25fSXin LIIt was enhanced to be mostly feature-compatible with the original
2209a9ea25fSXin LIGNU
2219a9ea25fSXin LI.Nm
2229a9ea25fSXin LIprogram for
2239a9ea25fSXin LI.Nx 2.0 .
2249a9ea25fSXin LI.Pp
2259a9ea25fSXin LIThis implementation of
2269a9ea25fSXin LI.Nm
2279a9ea25fSXin LIwas ported based on the
2289a9ea25fSXin LI.Nx
22990f528e8SXin LI.Nm
2305c4b64e6SXin LIversion 20181111,
231feeb03b2SXin LIand first appeared in
2329a9ea25fSXin LI.Fx 7.0 .
2339a9ea25fSXin LI.Sh AUTHORS
234feeb03b2SXin LI.An -nosplit
2359a9ea25fSXin LIThis implementation of
2369a9ea25fSXin LI.Nm
2379a9ea25fSXin LIwas written by
2382b7af31cSBaptiste Daroussin.An Matthew R. Green Aq Mt mrg@eterna.com.au
239feeb03b2SXin LIwith unpack support written by
2402b7af31cSBaptiste Daroussin.An Xin LI Aq Mt delphij@FreeBSD.org .
2412bab61b0SXin LI.Sh BUGS
2422bab61b0SXin LIAccording to RFC 1952, the recorded file size is stored in a 32-bit
2431edd4fcdSXin LIinteger, therefore, it cannot represent files larger than 4GB.
2441edd4fcdSXin LIThis limitation also applies to
2452bab61b0SXin LI.Fl l
2462bab61b0SXin LIoption of
2472bab61b0SXin LI.Nm
2482bab61b0SXin LIutility.
249