1. 2.TH "LZ4" "1" "August 2022" "lz4 v1.9.4" "User Commands" 3. 4.SH "NAME" 5\fBlz4\fR \- lz4, unlz4, lz4cat \- Compress or decompress \.lz4 files 6. 7.SH "SYNOPSIS" 8\fBlz4\fR [\fIOPTIONS\fR] [\-|INPUT\-FILE] \fIOUTPUT\-FILE\fR 9. 10.P 11\fBunlz4\fR is equivalent to \fBlz4 \-d\fR 12. 13.P 14\fBlz4cat\fR is equivalent to \fBlz4 \-dcfm\fR 15. 16.P 17When 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\. 18. 19.SH "DESCRIPTION" 20\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\. 21. 22.SS "Difference between lz4 and gzip" 23\fBlz4\fR supports a command line syntax similar \fIbut not identical\fR to \fBgzip(1)\fR\. Differences are : 24. 25.IP "\(bu" 4 26\fBlz4\fR compresses a single file by default (see \fB\-m\fR for multiple files) 27. 28.IP "\(bu" 4 29\fBlz4 file1 file2\fR means : compress file1 \fIinto\fR file2 30. 31.IP "\(bu" 4 32\fBlz4 file\.lz4\fR will default to decompression (use \fB\-z\fR to force compression) 33. 34.IP "\(bu" 4 35\fBlz4\fR preserves original files (see \fB\-\-rm\fR to erase source file on completion) 36. 37.IP "\(bu" 4 38\fBlz4\fR shows real\-time notification statistics during compression or decompression of a single file (use \fB\-q\fR to silence them) 39. 40.IP "\(bu" 4 41When 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\. 42. 43.IP "\(bu" 4 44It 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\. 45. 46.IP "" 0 47. 48.P 49Default behaviors can be modified by opt\-in commands, detailed below\. 50. 51.IP "\(bu" 4 52\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\. 53. 54.IP "\(bu" 4 55Similarly, \fBlz4 \-m \-d\fR can decompress multiple \fB*\.lz4\fR files\. 56. 57.IP "\(bu" 4 58It\'s possible to opt\-in to erase source files on successful compression or decompression, using \fB\-\-rm\fR command\. 59. 60.IP "\(bu" 4 61Consequently, \fBlz4 \-m \-\-rm\fR behaves the same as \fBgzip\fR\. 62. 63.IP "" 0 64. 65.SS "Concatenation of \.lz4 files" 66It 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: 67. 68.IP "" 4 69. 70.nf 71 72lz4 file1 > foo\.lz4 73lz4 file2 >> foo\.lz4 74. 75.fi 76. 77.IP "" 0 78. 79.P 80Then \fBlz4cat foo\.lz4\fR is equivalent to \fBcat file1 file2\fR\. 81. 82.SH "OPTIONS" 83. 84.SS "Short commands concatenation" 85In 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\. 86. 87.SS "Multiple commands" 88When multiple contradictory commands are issued on a same command line, only the latest one will be applied\. 89. 90.SS "Operation mode" 91. 92.TP 93\fB\-z\fR \fB\-\-compress\fR 94Compress\. 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\. 95. 96.TP 97\fB\-d\fR \fB\-\-decompress\fR \fB\-\-uncompress\fR 98Decompress\. \fB\-\-decompress\fR is also the default operation when the input filename has an \fB\.lz4\fR extension\. 99. 100.TP 101\fB\-t\fR \fB\-\-test\fR 102Test the integrity of compressed \fB\.lz4\fR files\. The decompressed data is discarded\. No files are created nor removed\. 103. 104.TP 105\fB\-b#\fR 106Benchmark mode, using \fB#\fR compression level\. 107. 108.TP 109\fB\-\-list\fR 110List information about \.lz4 files\. note : current implementation is limited to single\-frame \.lz4 files\. 111. 112.SS "Operation modifiers" 113. 114.TP 115\fB\-#\fR 116Compression 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\. 117. 118.TP 119\fB\-\-fast[=#]\fR 120Switch 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\. 121. 122.TP 123\fB\-\-best\fR 124Set highest compression level\. Same as \-12\. 125. 126.TP 127\fB\-\-favor\-decSpeed\fR 128Generate 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)\. 129. 130.TP 131\fB\-D dictionaryName\fR 132Compress, 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\. 133. 134.TP 135\fB\-f\fR \fB\-\-[no\-]force\fR 136This option has several effects: 137. 138.IP 139If the target file already exists, overwrite it without prompting\. 140. 141.IP 142When 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\. 143. 144.TP 145\fB\-c\fR \fB\-\-stdout\fR \fB\-\-to\-stdout\fR 146Force write to standard output, even if it is the console\. 147. 148.TP 149\fB\-m\fR \fB\-\-multiple\fR 150Multiple 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)\. 151. 152.TP 153\fB\-r\fR 154operate recursively on directories\. This mode also sets \fB\-m\fR (multiple input files)\. 155. 156.TP 157\fB\-B#\fR 158Block size [4\-7](default : 7) 159. 160.br 161\fB\-B4\fR= 64KB ; \fB\-B5\fR= 256KB ; \fB\-B6\fR= 1MB ; \fB\-B7\fR= 4MB 162. 163.TP 164\fB\-BI\fR 165Produce independent blocks (default) 166. 167.TP 168\fB\-BD\fR 169Blocks depend on predecessors (improves compression ratio, more noticeable on small blocks) 170. 171.TP 172\fB\-BX\fR 173Generate block checksums (default:disabled) 174. 175.TP 176\fB\-\-[no\-]frame\-crc\fR 177Select frame checksum (default:enabled) 178. 179.TP 180\fB\-\-no\-crc\fR 181Disable both frame and block checksums 182. 183.TP 184\fB\-\-[no\-]content\-size\fR 185Header includes original size (default:not present) 186. 187.br 188Note : 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\. 189. 190.TP 191\fB\-\-[no\-]sparse\fR 192Sparse mode support (default:enabled on file, disabled on stdout) 193. 194.TP 195\fB\-l\fR 196Use Legacy format (typically for Linux Kernel compression) 197. 198.br 199Note : \fB\-l\fR is not compatible with \fB\-m\fR (\fB\-\-multiple\fR) nor \fB\-r\fR 200. 201.SS "Other options" 202. 203.TP 204\fB\-v\fR \fB\-\-verbose\fR 205Verbose mode 206. 207.TP 208\fB\-q\fR \fB\-\-quiet\fR 209Suppress warnings and real\-time statistics; specify twice to suppress errors too 210. 211.TP 212\fB\-h\fR \fB\-H\fR \fB\-\-help\fR 213Display help/long help and exit 214. 215.TP 216\fB\-V\fR \fB\-\-version\fR 217Display Version number and exit 218. 219.TP 220\fB\-k\fR \fB\-\-keep\fR 221Preserve source files (default behavior) 222. 223.TP 224\fB\-\-rm\fR 225Delete source files on successful compression or decompression 226. 227.TP 228\fB\-\-\fR 229Treat all subsequent arguments as files 230. 231.SS "Benchmark mode" 232. 233.TP 234\fB\-b#\fR 235Benchmark file(s), using # compression level 236. 237.TP 238\fB\-e#\fR 239Benchmark multiple compression levels, from b# to e# (included) 240. 241.TP 242\fB\-i#\fR 243Minimum evaluation time in seconds [1\-9] (default : 3) 244. 245.SH "BUGS" 246Report bugs at: https://github\.com/lz4/lz4/issues 247. 248.SH "AUTHOR" 249Yann Collet 250