lz4 man page
lz4 — lz4, unlz4, lz4cat — Compress or decompress .lz4 files When writing scripts that need to decompress files, it is recommended to always use the name lz4 with appropriate arguments (lz4 -d or lz4 -dc) instead of the names unlz4 and lz4cat. lz4 is an extremely fast lossless compression algorithm, based on byte-aligned LZ77 family of compression scheme. lz4 offers compression speeds of 400 MB/s per core, linearly scalable with multi-core CPUs. It features an extremely fast decoder, with speed in multiple GB/s per core, typically reaching RAM speed limit on multi-core systems. The native file format is the .lz4 format. lz4 supports a command line syntax similar but not identical to gzip(1). Differences are : Default behaviors can be modified by opt-in commands, detailed below. It is possible to concatenate .lz4 files as is. lz4 will decompress such files as if they were a single .lz4 file. For example: Then lz4cat foo.lz4 is equivalent to cat file1 file2. In some cases, some options can be expressed using short command -x or long command --long-word. Short commands can be concatenated together. For example, -d -c is equivalent to -dc. Long commands cannot be concatenated. They must be clearly separated by a space. When multiple contradictory commands are issued on a same command line, only the latest one will be applied. Compress. 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, unlz4 implies --decompress), nor from the input file name (for example, a file extension .lz4 implies --decompress by default). -z can also be used to force compression of an already compressed .lz4 file. Decompress. --decompress is also the default operation when the input filename has an .lz4 extension. Test the integrity of compressed .lz4 files. The decompressed data is discarded. No files are created nor removed. Benchmark mode, using # compression level. List information about .lz4 files. note : current implementation is limited to single-frame .lz4 files. Compression 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. Switch to ultra-fast compression levels. The higher the value, the faster the compression speed, at the cost of some compression ratio. If =# is not present, it defaults to 1. This setting overrides compression level if one was set previously. Similarly, if a compression level is set after --fast, it overrides it. Generate 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). Compress, decompress or benchmark using dictionary dictionaryName. 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. This option has several effects: If the target file already exists, overwrite it without prompting. When used with --decompress and lz4 cannot recognize the type of the source file, copy the source file as is to standard output. This allows lz4cat --force to be used like cat (1) for files that have not been compressed with lz4. Force write to standard output, even if it is the console. Multiple input files. Compressed file names will be appended a .lz4 suffix. This mode also reduces notification level. Can also be used to list multiple files. lz4 -m has a behavior equivalent to gzip -k (it preserves source files by default). operate recursively on directories. This mode also sets -m (multiple input files). Block size [4-7](default : 7) Produce independent blocks (default) Blocks depend on predecessors (improves compression ratio, more noticeable on small blocks) Select frame checksum (default:enabled) Header includes original size (default:not present) Sparse mode support (default:enabled on file, disabled on stdout) Use Legacy format (typically for Linux Kernel compression) Verbose mode Suppress warnings and real-time statistics; specify twice to suppress errors too Display help/long help and exit Display Version number and exit Preserve source files (default behavior) Delete source files on successful compression or decompression Treat all subsequent arguments as files Report bugs at: https://github.com/lz4/lz4/issues Yann Collet The man pages lz4c(1), lz4cat(1) and unlz4(1) are aliases of lz4(1).Examples (TL;DR)
lz4 file
lz4 -d file.lz4
stdout
: lz4 -dc file.lz4
tar cvf - path/to/dir | lz4 - dir.tar.lz4
lz4 -d dir.tar.lz4 | tar -xv
lz4 -9 file
Synopsis
lz4 [Options] [-|INPUT-FILE] OUTPUT-FILE
unlz4 is equivalent to lz4 -d
lz4cat is equivalent to lz4 -dcfm
Description
Difference between lz4 and gzip
Concatenation of .lz4 files
lz4 file1 > foo.lz4
lz4 file2 >> foo.lz4
Options
Short commands concatenation
Multiple commands
Operation mode
Operation modifiers
-B4= 64KB ; -B5= 256KB ; -B6= 1MB ; -B7= 4MB
Note : 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.
Note : -l is not compatible with -m (--multiple) nor -rOther options
Benchmark mode
Bugs
Author
Referenced By