1LZ4(1) User Commands LZ4(1)
2
3
4
6 lz4 - lz4, unlz4, lz4cat - Compress or decompress .lz4 files
7
9 lz4 [OPTIONS] [-|INPUT-FILE] OUTPUT-FILE
10
11 unlz4 is equivalent to lz4 -d
12
13 lz4cat is equivalent to lz4 -dcfm
14
15 When writing scripts that need to decompress files, it is recommended
16 to always use the name lz4 with appropriate arguments (lz4 -d or lz4
17 -dc) instead of the names unlz4 and lz4cat.
18
20 lz4 is an extremely fast lossless compression algorithm, based on
21 byte-aligned LZ77 family of compression scheme. lz4 offers compression
22 speeds of 400 MB/s per core, linearly scalable with multi-core CPUs. It
23 features an extremely fast decoder, with speed in multiple GB/s per
24 core, typically reaching RAM speed limit on multi-core systems. The
25 native file format is the .lz4 format.
26
27 Difference between lz4 and gzip
28 lz4 supports a command line syntax similar but not identical to
29 gzip(1). Differences are :
30
31 · lz4 preserves original files
32
33 · lz4 compresses a single file by default (see -m for multiple files)
34
35 · lz4 file1 file2 means : compress file1 into file2
36
37 · lz4 shows real-time notification statistics during compression or
38 decompression of a single file (use -q to silent them)
39
40 · If no destination name is provided, result is sent to stdout except
41 if stdout is the console.
42
43 · If no destination name is provided, and if stdout is the console,
44 file is compressed into file.lz4.
45
46 · As a consequence of previous rules, note the following example :
47 lz4 file | consumer sends compressed data to consumer through std‐
48 out, hence it does not create any file.lz4.
49
50
51
52 Default behaviors can be modified by opt-in commands, detailed below.
53
54 · lz4 -m makes it possible to provide multiple input filenames, which
55 will be compressed into files using suffix .lz4. Progress notifica‐
56 tions are also disabled by default. This mode has a behavior which
57 more closely mimics gzip command line, with the main difference
58 being that source files are preserved by default.
59
60 · It´s possible to opt-in to erase source files on successful com‐
61 pression or decompression, using --rm command.
62
63 · Consequently, lz4 -m --rm behaves the same as gzip.
64
65
66
67 Concatenation of .lz4 files
68 It is possible to concatenate .lz4 files as is. lz4 will decompress
69 such files as if they were a single .lz4 file. For example: lz4 file1 >
70 foo.lz4 lz4 file2 >> foo.lz4
71
72 then lz4cat foo.lz4
73
74 is equivalent to : cat file1 file2
75
77 Short commands concatenation
78 In some cases, some options can be expressed using short command -x or
79 long command --long-word. Short commands can be concatenated together.
80 For example, -d -c is equivalent to -dc. Long commands cannot be con‐
81 catenated. They must be clearly separated by a space.
82
83 Multiple commands
84 When multiple contradictory commands are issued on a same command line,
85 only the latest one will be applied.
86
87 Operation mode
88 -z --compress
89 Compress. This is the default operation mode when no operation
90 mode option is specified, no other operation mode is implied
91 from the command name (for example, unlz4 implies --decompress),
92 nor from the input file name (for example, a file extension .lz4
93 implies --decompress by default). -z can also be used to force
94 compression of an already compressed .lz4 file.
95
96 -d --decompress --uncompress
97 Decompress. --decompress is also the default operation when the
98 input filename has an .lz4 extension.
99
100 -t --test
101 Test the integrity of compressed .lz4 files. The decompressed
102 data is discarded. No files are created nor removed.
103
104 -b# Benchmark mode, using # compression level.
105
106 Operation modifiers
107 -# Compression level, with # being any value from 1 to 16. Higher
108 values trade compression speed for compression ratio. Values
109 above 16 are considered the same as 16. Recommended values are 1
110 for fast compression (default), and 9 for high compression.
111 Speed/compression trade-off will vary depending on data to com‐
112 press. Decompression speed remains fast at all settings.
113
114 -f --[no-]force
115 This option has several effects:
116
117 If the target file already exists, overwrite it without prompt‐
118 ing.
119
120 When used with --decompress and lz4 cannot recognize the type of
121 the source file, copy the source file as is to standard output.
122 This allows lz4cat --force to be used like cat (1) for files
123 that have not been compressed with lz4.
124
125 -c --stdout --to-stdout
126 Force write to standard output, even if it is the console.
127
128 -m --multiple
129 Multiple input files. Compressed file names will be appended a
130 .lz4 suffix. This mode also reduces notification level. lz4 -m
131 has a behavior equivalent to gzip -k (it preserves source files
132 by default).
133
134 -r operate recursively on directories. This mode also sets -m (mul‐
135 tiple input files).
136
137 -B# Block size [4-7](default : 7)
138 -B4= 64KB ; -B5= 256KB ; -B6= 1MB ; -B7= 4MB
139
140 -BD Block Dependency (improves compression ratio on small blocks)
141
142 --[no-]frame-crc
143 Select frame checksum (default:enabled)
144
145 --[no-]content-size
146 Header includes original size (default:not present)
147 Note : this option can only be activated when the original size
148 can be determined, hence for a file. It won´t work with unknown
149 source size, such as stdin or pipe.
150
151 --[no-]sparse
152 Sparse mode support (default:enabled on file, disabled on std‐
153 out)
154
155 -l Use Legacy format (typically for Linux Kernel compression)
156 Note : -l is not compatible with -m (--multiple) nor -r
157
158 Other options
159 -v --verbose
160 Verbose mode
161
162 -q --quiet
163 Suppress warnings and real-time statistics; specify twice to
164 suppress errors too
165
166 -h -H --help
167 Display help/long help and exit
168
169 -V --version
170 Display Version number and exit
171
172 -k --keep
173 Preserve source files (default behavior)
174
175 --rm Delete source files on successful compression or decompression
176
177 Benchmark mode
178 -b# Benchmark file(s), using # compression level
179
180 -e# Benchmark multiple compression levels, from b# to e# (included)
181
182 -i# Minimum evaluation in seconds [1-9] (default : 3)
183
184 -r Operate recursively on directories
185
187 Report bugs at: https://github.com/lz4/lz4/issues
188
190 Yann Collet
191
192
193
194lz4 1.7.4 November 2016 LZ4(1)