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