127b27ec6Sopenharmony_ci.
227b27ec6Sopenharmony_ci.TH "LZ4" "1" "August 2022" "lz4 v1.9.4" "User Commands"
327b27ec6Sopenharmony_ci.
427b27ec6Sopenharmony_ci.SH "NAME"
527b27ec6Sopenharmony_ci\fBlz4\fR \- lz4, unlz4, lz4cat \- Compress or decompress \.lz4 files
627b27ec6Sopenharmony_ci.
727b27ec6Sopenharmony_ci.SH "SYNOPSIS"
827b27ec6Sopenharmony_ci\fBlz4\fR [\fIOPTIONS\fR] [\-|INPUT\-FILE] \fIOUTPUT\-FILE\fR
927b27ec6Sopenharmony_ci.
1027b27ec6Sopenharmony_ci.P
1127b27ec6Sopenharmony_ci\fBunlz4\fR is equivalent to \fBlz4 \-d\fR
1227b27ec6Sopenharmony_ci.
1327b27ec6Sopenharmony_ci.P
1427b27ec6Sopenharmony_ci\fBlz4cat\fR is equivalent to \fBlz4 \-dcfm\fR
1527b27ec6Sopenharmony_ci.
1627b27ec6Sopenharmony_ci.P
1727b27ec6Sopenharmony_ciWhen writing scripts that need to decompress files, it is recommended to always use the name \fBlz4\fR with appropriate arguments (\fBlz4 \-d\fR or \fBlz4 \-dc\fR) instead of the names \fBunlz4\fR and \fBlz4cat\fR\.
1827b27ec6Sopenharmony_ci.
1927b27ec6Sopenharmony_ci.SH "DESCRIPTION"
2027b27ec6Sopenharmony_ci\fBlz4\fR is an extremely fast lossless compression algorithm, based on \fBbyte\-aligned LZ77\fR family of compression scheme\. \fBlz4\fR offers compression speeds > 500 MB/s per core, linearly scalable with multi\-core CPUs\. It features an extremely fast decoder, offering speed in multiple GB/s per core, typically reaching RAM speed limit on multi\-core systems\. The native file format is the \fB\.lz4\fR format\.
2127b27ec6Sopenharmony_ci.
2227b27ec6Sopenharmony_ci.SS "Difference between lz4 and gzip"
2327b27ec6Sopenharmony_ci\fBlz4\fR supports a command line syntax similar \fIbut not identical\fR to \fBgzip(1)\fR\. Differences are :
2427b27ec6Sopenharmony_ci.
2527b27ec6Sopenharmony_ci.IP "\(bu" 4
2627b27ec6Sopenharmony_ci\fBlz4\fR compresses a single file by default (see \fB\-m\fR for multiple files)
2727b27ec6Sopenharmony_ci.
2827b27ec6Sopenharmony_ci.IP "\(bu" 4
2927b27ec6Sopenharmony_ci\fBlz4 file1 file2\fR means : compress file1 \fIinto\fR file2
3027b27ec6Sopenharmony_ci.
3127b27ec6Sopenharmony_ci.IP "\(bu" 4
3227b27ec6Sopenharmony_ci\fBlz4 file\.lz4\fR will default to decompression (use \fB\-z\fR to force compression)
3327b27ec6Sopenharmony_ci.
3427b27ec6Sopenharmony_ci.IP "\(bu" 4
3527b27ec6Sopenharmony_ci\fBlz4\fR preserves original files (see \fB\-\-rm\fR to erase source file on completion)
3627b27ec6Sopenharmony_ci.
3727b27ec6Sopenharmony_ci.IP "\(bu" 4
3827b27ec6Sopenharmony_ci\fBlz4\fR shows real\-time notification statistics during compression or decompression of a single file (use \fB\-q\fR to silence them)
3927b27ec6Sopenharmony_ci.
4027b27ec6Sopenharmony_ci.IP "\(bu" 4
4127b27ec6Sopenharmony_ciWhen no destination is specified, result is sent on implicit output, which depends on \fBstdout\fR status\. When \fBstdout\fR \fIis Not the console\fR, it becomes the implicit output\. Otherwise, if \fBstdout\fR is the console, the implicit output is \fBfilename\.lz4\fR\.
4227b27ec6Sopenharmony_ci.
4327b27ec6Sopenharmony_ci.IP "\(bu" 4
4427b27ec6Sopenharmony_ciIt is considered bad practice to rely on implicit output in scripts\. because the script\'s environment may change\. Always use explicit output in scripts\. \fB\-c\fR ensures that output will be \fBstdout\fR\. Conversely, providing a destination name, or using \fB\-m\fR ensures that the output will be either the specified name, or \fBfilename\.lz4\fR respectively\.
4527b27ec6Sopenharmony_ci.
4627b27ec6Sopenharmony_ci.IP "" 0
4727b27ec6Sopenharmony_ci.
4827b27ec6Sopenharmony_ci.P
4927b27ec6Sopenharmony_ciDefault behaviors can be modified by opt\-in commands, detailed below\.
5027b27ec6Sopenharmony_ci.
5127b27ec6Sopenharmony_ci.IP "\(bu" 4
5227b27ec6Sopenharmony_ci\fBlz4 \-m\fR makes it possible to provide multiple input filenames, which will be compressed into files using suffix \fB\.lz4\fR\. Progress notifications become disabled by default (use \fB\-v\fR to enable them)\. This mode has a behavior which more closely mimics \fBgzip\fR command line, with the main remaining difference being that source files are preserved by default\.
5327b27ec6Sopenharmony_ci.
5427b27ec6Sopenharmony_ci.IP "\(bu" 4
5527b27ec6Sopenharmony_ciSimilarly, \fBlz4 \-m \-d\fR can decompress multiple \fB*\.lz4\fR files\.
5627b27ec6Sopenharmony_ci.
5727b27ec6Sopenharmony_ci.IP "\(bu" 4
5827b27ec6Sopenharmony_ciIt\'s possible to opt\-in to erase source files on successful compression or decompression, using \fB\-\-rm\fR command\.
5927b27ec6Sopenharmony_ci.
6027b27ec6Sopenharmony_ci.IP "\(bu" 4
6127b27ec6Sopenharmony_ciConsequently, \fBlz4 \-m \-\-rm\fR behaves the same as \fBgzip\fR\.
6227b27ec6Sopenharmony_ci.
6327b27ec6Sopenharmony_ci.IP "" 0
6427b27ec6Sopenharmony_ci.
6527b27ec6Sopenharmony_ci.SS "Concatenation of \.lz4 files"
6627b27ec6Sopenharmony_ciIt is possible to concatenate \fB\.lz4\fR files as is\. \fBlz4\fR will decompress such files as if they were a single \fB\.lz4\fR file\. For example:
6727b27ec6Sopenharmony_ci.
6827b27ec6Sopenharmony_ci.IP "" 4
6927b27ec6Sopenharmony_ci.
7027b27ec6Sopenharmony_ci.nf
7127b27ec6Sopenharmony_ci
7227b27ec6Sopenharmony_cilz4 file1  > foo\.lz4
7327b27ec6Sopenharmony_cilz4 file2 >> foo\.lz4
7427b27ec6Sopenharmony_ci.
7527b27ec6Sopenharmony_ci.fi
7627b27ec6Sopenharmony_ci.
7727b27ec6Sopenharmony_ci.IP "" 0
7827b27ec6Sopenharmony_ci.
7927b27ec6Sopenharmony_ci.P
8027b27ec6Sopenharmony_ciThen \fBlz4cat foo\.lz4\fR is equivalent to \fBcat file1 file2\fR\.
8127b27ec6Sopenharmony_ci.
8227b27ec6Sopenharmony_ci.SH "OPTIONS"
8327b27ec6Sopenharmony_ci.
8427b27ec6Sopenharmony_ci.SS "Short commands concatenation"
8527b27ec6Sopenharmony_ciIn some cases, some options can be expressed using short command \fB\-x\fR or long command \fB\-\-long\-word\fR\. Short commands can be concatenated together\. For example, \fB\-d \-c\fR is equivalent to \fB\-dc\fR\. Long commands cannot be concatenated\. They must be clearly separated by a space\.
8627b27ec6Sopenharmony_ci.
8727b27ec6Sopenharmony_ci.SS "Multiple commands"
8827b27ec6Sopenharmony_ciWhen multiple contradictory commands are issued on a same command line, only the latest one will be applied\.
8927b27ec6Sopenharmony_ci.
9027b27ec6Sopenharmony_ci.SS "Operation mode"
9127b27ec6Sopenharmony_ci.
9227b27ec6Sopenharmony_ci.TP
9327b27ec6Sopenharmony_ci\fB\-z\fR \fB\-\-compress\fR
9427b27ec6Sopenharmony_ciCompress\. This is the default operation mode when no operation mode option is specified, no other operation mode is implied from the command name (for example, \fBunlz4\fR implies \fB\-\-decompress\fR), nor from the input file name (for example, a file extension \fB\.lz4\fR implies \fB\-\-decompress\fR by default)\. \fB\-z\fR can also be used to force compression of an already compressed \fB\.lz4\fR file\.
9527b27ec6Sopenharmony_ci.
9627b27ec6Sopenharmony_ci.TP
9727b27ec6Sopenharmony_ci\fB\-d\fR \fB\-\-decompress\fR \fB\-\-uncompress\fR
9827b27ec6Sopenharmony_ciDecompress\. \fB\-\-decompress\fR is also the default operation when the input filename has an \fB\.lz4\fR extension\.
9927b27ec6Sopenharmony_ci.
10027b27ec6Sopenharmony_ci.TP
10127b27ec6Sopenharmony_ci\fB\-t\fR \fB\-\-test\fR
10227b27ec6Sopenharmony_ciTest the integrity of compressed \fB\.lz4\fR files\. The decompressed data is discarded\. No files are created nor removed\.
10327b27ec6Sopenharmony_ci.
10427b27ec6Sopenharmony_ci.TP
10527b27ec6Sopenharmony_ci\fB\-b#\fR
10627b27ec6Sopenharmony_ciBenchmark mode, using \fB#\fR compression level\.
10727b27ec6Sopenharmony_ci.
10827b27ec6Sopenharmony_ci.TP
10927b27ec6Sopenharmony_ci\fB\-\-list\fR
11027b27ec6Sopenharmony_ciList information about \.lz4 files\. note : current implementation is limited to single\-frame \.lz4 files\.
11127b27ec6Sopenharmony_ci.
11227b27ec6Sopenharmony_ci.SS "Operation modifiers"
11327b27ec6Sopenharmony_ci.
11427b27ec6Sopenharmony_ci.TP
11527b27ec6Sopenharmony_ci\fB\-#\fR
11627b27ec6Sopenharmony_ciCompression level, with # being any value from 1 to 12\. Higher values trade compression speed for compression ratio\. Values above 12 are considered the same as 12\. Recommended values are 1 for fast compression (default), and 9 for high compression\. Speed/compression trade\-off will vary depending on data to compress\. Decompression speed remains fast at all settings\.
11727b27ec6Sopenharmony_ci.
11827b27ec6Sopenharmony_ci.TP
11927b27ec6Sopenharmony_ci\fB\-\-fast[=#]\fR
12027b27ec6Sopenharmony_ciSwitch to ultra\-fast compression levels\. The higher the value, the faster the compression speed, at the cost of some compression ratio\. If \fB=#\fR is not present, it defaults to \fB1\fR\. This setting overrides compression level if one was set previously\. Similarly, if a compression level is set after \fB\-\-fast\fR, it overrides it\.
12127b27ec6Sopenharmony_ci.
12227b27ec6Sopenharmony_ci.TP
12327b27ec6Sopenharmony_ci\fB\-\-best\fR
12427b27ec6Sopenharmony_ciSet highest compression level\. Same as \-12\.
12527b27ec6Sopenharmony_ci.
12627b27ec6Sopenharmony_ci.TP
12727b27ec6Sopenharmony_ci\fB\-\-favor\-decSpeed\fR
12827b27ec6Sopenharmony_ciGenerate compressed data optimized for decompression speed\. Compressed data will be larger as a consequence (typically by ~0\.5%), while decompression speed will be improved by 5\-20%, depending on use cases\. This option only works in combination with very high compression levels (>=10)\.
12927b27ec6Sopenharmony_ci.
13027b27ec6Sopenharmony_ci.TP
13127b27ec6Sopenharmony_ci\fB\-D dictionaryName\fR
13227b27ec6Sopenharmony_ciCompress, decompress or benchmark using dictionary \fIdictionaryName\fR\. Compression and decompression must use the same dictionary to be compatible\. Using a different dictionary during decompression will either abort due to decompression error, or generate a checksum error\.
13327b27ec6Sopenharmony_ci.
13427b27ec6Sopenharmony_ci.TP
13527b27ec6Sopenharmony_ci\fB\-f\fR \fB\-\-[no\-]force\fR
13627b27ec6Sopenharmony_ciThis option has several effects:
13727b27ec6Sopenharmony_ci.
13827b27ec6Sopenharmony_ci.IP
13927b27ec6Sopenharmony_ciIf the target file already exists, overwrite it without prompting\.
14027b27ec6Sopenharmony_ci.
14127b27ec6Sopenharmony_ci.IP
14227b27ec6Sopenharmony_ciWhen used with \fB\-\-decompress\fR and \fBlz4\fR cannot recognize the type of the source file, copy the source file as is to standard output\. This allows \fBlz4cat \-\-force\fR to be used like \fBcat (1)\fR for files that have not been compressed with \fBlz4\fR\.
14327b27ec6Sopenharmony_ci.
14427b27ec6Sopenharmony_ci.TP
14527b27ec6Sopenharmony_ci\fB\-c\fR \fB\-\-stdout\fR \fB\-\-to\-stdout\fR
14627b27ec6Sopenharmony_ciForce write to standard output, even if it is the console\.
14727b27ec6Sopenharmony_ci.
14827b27ec6Sopenharmony_ci.TP
14927b27ec6Sopenharmony_ci\fB\-m\fR \fB\-\-multiple\fR
15027b27ec6Sopenharmony_ciMultiple input files\. Compressed file names will be appended a \fB\.lz4\fR suffix\. This mode also reduces notification level\. Can also be used to list multiple files\. \fBlz4 \-m\fR has a behavior equivalent to \fBgzip \-k\fR (it preserves source files by default)\.
15127b27ec6Sopenharmony_ci.
15227b27ec6Sopenharmony_ci.TP
15327b27ec6Sopenharmony_ci\fB\-r\fR
15427b27ec6Sopenharmony_cioperate recursively on directories\. This mode also sets \fB\-m\fR (multiple input files)\.
15527b27ec6Sopenharmony_ci.
15627b27ec6Sopenharmony_ci.TP
15727b27ec6Sopenharmony_ci\fB\-B#\fR
15827b27ec6Sopenharmony_ciBlock size [4\-7](default : 7)
15927b27ec6Sopenharmony_ci.
16027b27ec6Sopenharmony_ci.br
16127b27ec6Sopenharmony_ci\fB\-B4\fR= 64KB ; \fB\-B5\fR= 256KB ; \fB\-B6\fR= 1MB ; \fB\-B7\fR= 4MB
16227b27ec6Sopenharmony_ci.
16327b27ec6Sopenharmony_ci.TP
16427b27ec6Sopenharmony_ci\fB\-BI\fR
16527b27ec6Sopenharmony_ciProduce independent blocks (default)
16627b27ec6Sopenharmony_ci.
16727b27ec6Sopenharmony_ci.TP
16827b27ec6Sopenharmony_ci\fB\-BD\fR
16927b27ec6Sopenharmony_ciBlocks depend on predecessors (improves compression ratio, more noticeable on small blocks)
17027b27ec6Sopenharmony_ci.
17127b27ec6Sopenharmony_ci.TP
17227b27ec6Sopenharmony_ci\fB\-BX\fR
17327b27ec6Sopenharmony_ciGenerate block checksums (default:disabled)
17427b27ec6Sopenharmony_ci.
17527b27ec6Sopenharmony_ci.TP
17627b27ec6Sopenharmony_ci\fB\-\-[no\-]frame\-crc\fR
17727b27ec6Sopenharmony_ciSelect frame checksum (default:enabled)
17827b27ec6Sopenharmony_ci.
17927b27ec6Sopenharmony_ci.TP
18027b27ec6Sopenharmony_ci\fB\-\-no\-crc\fR
18127b27ec6Sopenharmony_ciDisable both frame and block checksums
18227b27ec6Sopenharmony_ci.
18327b27ec6Sopenharmony_ci.TP
18427b27ec6Sopenharmony_ci\fB\-\-[no\-]content\-size\fR
18527b27ec6Sopenharmony_ciHeader includes original size (default:not present)
18627b27ec6Sopenharmony_ci.
18727b27ec6Sopenharmony_ci.br
18827b27ec6Sopenharmony_ciNote : this option can only be activated when the original size can be determined, hence for a file\. It won\'t work with unknown source size, such as stdin or pipe\.
18927b27ec6Sopenharmony_ci.
19027b27ec6Sopenharmony_ci.TP
19127b27ec6Sopenharmony_ci\fB\-\-[no\-]sparse\fR
19227b27ec6Sopenharmony_ciSparse mode support (default:enabled on file, disabled on stdout)
19327b27ec6Sopenharmony_ci.
19427b27ec6Sopenharmony_ci.TP
19527b27ec6Sopenharmony_ci\fB\-l\fR
19627b27ec6Sopenharmony_ciUse Legacy format (typically for Linux Kernel compression)
19727b27ec6Sopenharmony_ci.
19827b27ec6Sopenharmony_ci.br
19927b27ec6Sopenharmony_ciNote : \fB\-l\fR is not compatible with \fB\-m\fR (\fB\-\-multiple\fR) nor \fB\-r\fR
20027b27ec6Sopenharmony_ci.
20127b27ec6Sopenharmony_ci.SS "Other options"
20227b27ec6Sopenharmony_ci.
20327b27ec6Sopenharmony_ci.TP
20427b27ec6Sopenharmony_ci\fB\-v\fR \fB\-\-verbose\fR
20527b27ec6Sopenharmony_ciVerbose mode
20627b27ec6Sopenharmony_ci.
20727b27ec6Sopenharmony_ci.TP
20827b27ec6Sopenharmony_ci\fB\-q\fR \fB\-\-quiet\fR
20927b27ec6Sopenharmony_ciSuppress warnings and real\-time statistics; specify twice to suppress errors too
21027b27ec6Sopenharmony_ci.
21127b27ec6Sopenharmony_ci.TP
21227b27ec6Sopenharmony_ci\fB\-h\fR \fB\-H\fR \fB\-\-help\fR
21327b27ec6Sopenharmony_ciDisplay help/long help and exit
21427b27ec6Sopenharmony_ci.
21527b27ec6Sopenharmony_ci.TP
21627b27ec6Sopenharmony_ci\fB\-V\fR \fB\-\-version\fR
21727b27ec6Sopenharmony_ciDisplay Version number and exit
21827b27ec6Sopenharmony_ci.
21927b27ec6Sopenharmony_ci.TP
22027b27ec6Sopenharmony_ci\fB\-k\fR \fB\-\-keep\fR
22127b27ec6Sopenharmony_ciPreserve source files (default behavior)
22227b27ec6Sopenharmony_ci.
22327b27ec6Sopenharmony_ci.TP
22427b27ec6Sopenharmony_ci\fB\-\-rm\fR
22527b27ec6Sopenharmony_ciDelete source files on successful compression or decompression
22627b27ec6Sopenharmony_ci.
22727b27ec6Sopenharmony_ci.TP
22827b27ec6Sopenharmony_ci\fB\-\-\fR
22927b27ec6Sopenharmony_ciTreat all subsequent arguments as files
23027b27ec6Sopenharmony_ci.
23127b27ec6Sopenharmony_ci.SS "Benchmark mode"
23227b27ec6Sopenharmony_ci.
23327b27ec6Sopenharmony_ci.TP
23427b27ec6Sopenharmony_ci\fB\-b#\fR
23527b27ec6Sopenharmony_ciBenchmark file(s), using # compression level
23627b27ec6Sopenharmony_ci.
23727b27ec6Sopenharmony_ci.TP
23827b27ec6Sopenharmony_ci\fB\-e#\fR
23927b27ec6Sopenharmony_ciBenchmark multiple compression levels, from b# to e# (included)
24027b27ec6Sopenharmony_ci.
24127b27ec6Sopenharmony_ci.TP
24227b27ec6Sopenharmony_ci\fB\-i#\fR
24327b27ec6Sopenharmony_ciMinimum evaluation time in seconds [1\-9] (default : 3)
24427b27ec6Sopenharmony_ci.
24527b27ec6Sopenharmony_ci.SH "BUGS"
24627b27ec6Sopenharmony_ciReport bugs at: https://github\.com/lz4/lz4/issues
24727b27ec6Sopenharmony_ci.
24827b27ec6Sopenharmony_ci.SH "AUTHOR"
24927b27ec6Sopenharmony_ciYann Collet
250