1 1.1 christos Command Line Interface for Zstandard library 2 1.1 christos ============================================ 3 1.1 christos 4 1.1 christos Command Line Interface (CLI) can be created using the `make` command without any additional parameters. 5 1.1 christos There are however other Makefile targets that create different variations of CLI: 6 1.1 christos - `zstd` : default CLI supporting gzip-like arguments; includes dictionary builder, benchmark, and supports decompression of legacy zstd formats 7 1.1 christos - `zstd_nolegacy` : Same as `zstd` but without support for legacy zstd formats 8 1.1 christos - `zstd-small` : CLI optimized for minimal size; no dictionary builder, no benchmark, and no support for legacy zstd formats 9 1.1 christos - `zstd-compress` : version of CLI which can only compress into zstd format 10 1.1 christos - `zstd-decompress` : version of CLI which can only decompress zstd format 11 1.1 christos 12 1.1 christos 13 1.1 christos ### Compilation variables 14 1.1 christos `zstd` scope can be altered by modifying the following `make` variables : 15 1.1 christos 16 1.1 christos - __HAVE_THREAD__ : multithreading is automatically enabled when `pthread` is detected. 17 1.1 christos It's possible to disable multithread support, by setting `HAVE_THREAD=0`. 18 1.1 christos Example : `make zstd HAVE_THREAD=0` 19 1.1 christos It's also possible to force multithread support, using `HAVE_THREAD=1`. 20 1.1 christos In which case, linking stage will fail if neither `pthread` nor `windows.h` library can be found. 21 1.1 christos This is useful to ensure this feature is not silently disabled. 22 1.1 christos 23 1.1 christos - __ZSTD_LEGACY_SUPPORT__ : `zstd` can decompress files compressed by older versions of `zstd`. 24 1.1 christos Starting v0.8.0, all versions of `zstd` produce frames compliant with the [specification](../doc/zstd_compression_format.md), and are therefore compatible. 25 1.1 christos But older versions (< v0.8.0) produced different, incompatible, frames. 26 1.1 christos By default, `zstd` supports decoding legacy formats >= v0.4.0 (`ZSTD_LEGACY_SUPPORT=4`). 27 1.1 christos This can be altered by modifying this compilation variable. 28 1.1 christos `ZSTD_LEGACY_SUPPORT=1` means "support all formats >= v0.1.0". 29 1.1 christos `ZSTD_LEGACY_SUPPORT=2` means "support all formats >= v0.2.0", and so on. 30 1.1 christos `ZSTD_LEGACY_SUPPORT=0` means _DO NOT_ support any legacy format. 31 1.1 christos if `ZSTD_LEGACY_SUPPORT >= 8`, it's the same as `0`, since there is no legacy format after `7`. 32 1.1 christos Note : `zstd` only supports decoding older formats, and cannot generate any legacy format. 33 1.1 christos 34 1.1 christos - __HAVE_ZLIB__ : `zstd` can compress and decompress files in `.gz` format. 35 1.1 christos This is ordered through command `--format=gzip`. 36 1.1 christos Alternatively, symlinks named `gzip` or `gunzip` will mimic intended behavior. 37 1.1 christos `.gz` support is automatically enabled when `zlib` library is detected at build time. 38 1.1 christos It's possible to disable `.gz` support, by setting `HAVE_ZLIB=0`. 39 1.1 christos Example : `make zstd HAVE_ZLIB=0` 40 1.1 christos It's also possible to force compilation with zlib support, using `HAVE_ZLIB=1`. 41 1.1 christos In which case, linking stage will fail if `zlib` library cannot be found. 42 1.1 christos This is useful to prevent silent feature disabling. 43 1.1 christos 44 1.1 christos - __HAVE_LZMA__ : `zstd` can compress and decompress files in `.xz` and `.lzma` formats. 45 1.1 christos This is ordered through commands `--format=xz` and `--format=lzma` respectively. 46 1.1 christos Alternatively, symlinks named `xz`, `unxz`, `lzma`, or `unlzma` will mimic intended behavior. 47 1.1 christos `.xz` and `.lzma` support is automatically enabled when `lzma` library is detected at build time. 48 1.1 christos It's possible to disable `.xz` and `.lzma` support, by setting `HAVE_LZMA=0`. 49 1.1 christos Example : `make zstd HAVE_LZMA=0` 50 1.1 christos It's also possible to force compilation with lzma support, using `HAVE_LZMA=1`. 51 1.1 christos In which case, linking stage will fail if `lzma` library cannot be found. 52 1.1 christos This is useful to prevent silent feature disabling. 53 1.1 christos 54 1.1 christos - __HAVE_LZ4__ : `zstd` can compress and decompress files in `.lz4` formats. 55 1.1 christos This is ordered through commands `--format=lz4`. 56 1.1 christos Alternatively, symlinks named `lz4`, or `unlz4` will mimic intended behavior. 57 1.1 christos `.lz4` support is automatically enabled when `lz4` library is detected at build time. 58 1.1 christos It's possible to disable `.lz4` support, by setting `HAVE_LZ4=0` . 59 1.1 christos Example : `make zstd HAVE_LZ4=0` 60 1.1 christos It's also possible to force compilation with lz4 support, using `HAVE_LZ4=1`. 61 1.1 christos In which case, linking stage will fail if `lz4` library cannot be found. 62 1.1 christos This is useful to prevent silent feature disabling. 63 1.1 christos 64 1.1 christos - __ZSTD_NOBENCH__ : `zstd` cli will be compiled without its integrated benchmark module. 65 1.1 christos This can be useful to produce smaller binaries. 66 1.1 christos In this case, the corresponding unit can also be excluded from compilation target. 67 1.1 christos 68 1.1 christos - __ZSTD_NODICT__ : `zstd` cli will be compiled without support for the integrated dictionary builder. 69 1.1 christos This can be useful to produce smaller binaries. 70 1.1 christos In this case, the corresponding unit can also be excluded from compilation target. 71 1.1 christos 72 1.1 christos - __ZSTD_NOCOMPRESS__ : `zstd` cli will be compiled without support for compression. 73 1.1 christos The resulting binary will only be able to decompress files. 74 1.1 christos This can be useful to produce smaller binaries. 75 1.1 christos A corresponding `Makefile` target using this ability is `zstd-decompress`. 76 1.1 christos 77 1.1 christos - __ZSTD_NODECOMPRESS__ : `zstd` cli will be compiled without support for decompression. 78 1.1 christos The resulting binary will only be able to compress files. 79 1.1 christos This can be useful to produce smaller binaries. 80 1.1 christos A corresponding `Makefile` target using this ability is `zstd-compress`. 81 1.1 christos 82 1.1 christos - __BACKTRACE__ : `zstd` can display a stack backtrace when execution 83 1.1 christos generates a runtime exception. By default, this feature may be 84 1.1 christos degraded/disabled on some platforms unless additional compiler directives are 85 1.1 christos applied. When triaging a runtime issue, enabling this feature can provide 86 1.1 christos more context to determine the location of the fault. 87 1.1 christos Example : `make zstd BACKTRACE=1` 88 1.1 christos 89 1.1 christos 90 1.1 christos ### Aggregation of parameters 91 1.1 christos CLI supports aggregation of parameters i.e. `-b1`, `-e18`, and `-i1` can be joined into `-b1e18i1`. 92 1.1 christos 93 1.1 christos 94 1.1 christos ### Symlink shortcuts 95 1.1 christos It's possible to invoke `zstd` through a symlink. 96 1.1 christos When the name of the symlink has a specific value, it triggers an associated behavior. 97 1.1 christos - `zstdmt` : compress using all cores available on local system. 98 1.1 christos - `zcat` : will decompress and output target file using any of the supported formats. `gzcat` and `zstdcat` are also equivalent. 99 1.1 christos - `gzip` : if zlib support is enabled, will mimic `gzip` by compressing file using `.gz` format, removing source file by default (use `--keep` to preserve). If zlib is not supported, triggers an error. 100 1.1 christos - `xz` : if lzma support is enabled, will mimic `xz` by compressing file using `.xz` format, removing source file by default (use `--keep` to preserve). If xz is not supported, triggers an error. 101 1.1 christos - `lzma` : if lzma support is enabled, will mimic `lzma` by compressing file using `.lzma` format, removing source file by default (use `--keep` to preserve). If lzma is not supported, triggers an error. 102 1.1 christos - `lz4` : if lz4 support is enabled, will mimic `lz4` by compressing file using `.lz4` format. If lz4 is not supported, triggers an error. 103 1.1 christos - `unzstd` and `unlz4` will decompress any of the supported format. 104 1.1 christos - `ungz`, `unxz` and `unlzma` will do the same, and will also remove source file by default (use `--keep` to preserve). 105 1.1 christos 106 1.1 christos 107 1.1 christos ### Dictionary builder in Command Line Interface 108 1.1 christos Zstd offers a training mode, which can be used to tune the algorithm for a selected 109 1.1 christos type of data, by providing it with a few samples. The result of the training is stored 110 1.1 christos in a file selected with the `-o` option (default name is `dictionary`), 111 1.1 christos which can be loaded before compression and decompression. 112 1.1 christos 113 1.1 christos Using a dictionary, the compression ratio achievable on small data improves dramatically. 114 1.1 christos These compression gains are achieved while simultaneously providing faster compression and decompression speeds. 115 1.1 christos Dictionary work if there is some correlation in a family of small data (there is no universal dictionary). 116 1.1 christos Hence, deploying one dictionary per type of data will provide the greater benefits. 117 1.1 christos Dictionary gains are mostly effective in the first few KB. Then, the compression algorithm 118 1.1 christos will rely more and more on previously decoded content to compress the rest of the file. 119 1.1 christos 120 1.1 christos Usage of the dictionary builder and created dictionaries with CLI: 121 1.1 christos 122 1.1 christos 1. Create the dictionary : `zstd --train PathToTrainingSet/* -o dictionaryName` 123 1.1 christos 2. Compress with the dictionary: `zstd FILE -D dictionaryName` 124 1.1 christos 3. Decompress with the dictionary: `zstd --decompress FILE.zst -D dictionaryName` 125 1.1 christos 126 1.1 christos 127 1.1 christos ### Benchmark in Command Line Interface 128 1.1 christos CLI includes in-memory compression benchmark module for zstd. 129 1.1 christos The benchmark is conducted using given filenames. The files are read into memory and joined together. 130 1.1 christos It makes benchmark more precise as it eliminates I/O overhead. 131 1.1 christos Multiple filenames can be supplied, as multiple parameters, with wildcards, 132 1.1.1.2 christos or directory names can be used with `-r` option. 133 1.1.1.2 christos If no file is provided, the benchmark will use a procedurally generated "lorem ipsum" content. 134 1.1 christos 135 1.1 christos The benchmark measures ratio, compressed size, compression and decompression speed. 136 1.1 christos One can select compression levels starting from `-b` and ending with `-e`. 137 1.1 christos The `-i` parameter selects minimal time used for each of tested levels. 138 1.1 christos 139 1.1.1.2 christos The benchmark can also be used to test specific parameters, 140 1.1.1.2 christos such as number of threads (`-T#`), or advanced parameters (`--zstd=#`), or dictionary compression (`-D DICTIONARY`), 141 1.1.1.2 christos and many others available on command for regular compression and decompression. 142 1.1.1.2 christos 143 1.1 christos 144 1.1 christos ### Usage of Command Line Interface 145 1.1 christos The full list of options can be obtained with `-h` or `-H` parameter: 146 1.1 christos ``` 147 1.1.1.2 christos *** Zstandard CLI (64-bit) v1.5.6, by Yann Collet *** 148 1.1.1.2 christos 149 1.1.1.2 christos Compress or decompress the INPUT file(s); reads from STDIN if INPUT is `-` or not provided. 150 1.1.1.2 christos 151 1.1.1.2 christos Usage: zstd [OPTIONS...] [INPUT... | -] [-o OUTPUT] 152 1.1 christos 153 1.1.1.2 christos Options: 154 1.1.1.2 christos -o OUTPUT Write output to a single file, OUTPUT. 155 1.1.1.2 christos -k, --keep Preserve INPUT file(s). [Default] 156 1.1.1.2 christos --rm Remove INPUT file(s) after successful (de)compression. 157 1.1.1.2 christos 158 1.1.1.2 christos -# Desired compression level, where `#` is a number between 1 and 19; 159 1.1.1.2 christos lower numbers provide faster compression, higher numbers yield 160 1.1.1.2 christos better compression ratios. [Default: 3] 161 1.1.1.2 christos 162 1.1.1.2 christos -d, --decompress Perform decompression. 163 1.1.1.2 christos -D DICT Use DICT as the dictionary for compression or decompression. 164 1.1.1.2 christos 165 1.1.1.2 christos -f, --force Disable input and output checks. Allows overwriting existing files, 166 1.1.1.2 christos receiving input from the console, printing output to STDOUT, and 167 1.1.1.2 christos operating on links, block devices, etc. Unrecognized formats will be 168 1.1.1.2 christos passed-through through as-is. 169 1.1.1.2 christos 170 1.1.1.2 christos -h Display short usage and exit. 171 1.1.1.2 christos -H, --help Display full help and exit. 172 1.1.1.2 christos -V, --version Display the program version and exit. 173 1.1.1.2 christos 174 1.1.1.2 christos Advanced options: 175 1.1.1.2 christos -c, --stdout Write to STDOUT (even if it is a console) and keep the INPUT file(s). 176 1.1.1.2 christos 177 1.1.1.2 christos -v, --verbose Enable verbose output; pass multiple times to increase verbosity. 178 1.1.1.2 christos -q, --quiet Suppress warnings; pass twice to suppress errors. 179 1.1.1.2 christos --trace LOG Log tracing information to LOG. 180 1.1.1.2 christos 181 1.1.1.2 christos --[no-]progress Forcibly show/hide the progress counter. NOTE: Any (de)compressed 182 1.1.1.2 christos output to terminal will mix with progress counter text. 183 1.1.1.2 christos 184 1.1.1.2 christos -r Operate recursively on directories. 185 1.1.1.2 christos --filelist LIST Read a list of files to operate on from LIST. 186 1.1.1.2 christos --output-dir-flat DIR Store processed files in DIR. 187 1.1.1.2 christos --output-dir-mirror DIR Store processed files in DIR, respecting original directory structure. 188 1.1.1.2 christos --[no-]asyncio Use asynchronous IO. [Default: Enabled] 189 1.1.1.2 christos 190 1.1.1.2 christos --[no-]check Add XXH64 integrity checksums during compression. [Default: Add, Validate] 191 1.1.1.2 christos If `-d` is present, ignore/validate checksums during decompression. 192 1.1.1.2 christos 193 1.1.1.2 christos -- Treat remaining arguments after `--` as files. 194 1.1.1.2 christos 195 1.1.1.2 christos Advanced compression options: 196 1.1.1.2 christos --ultra Enable levels beyond 19, up to 22; requires more memory. 197 1.1.1.2 christos --fast[=#] Use to very fast compression levels. [Default: 1] 198 1.1.1.2 christos --adapt Dynamically adapt compression level to I/O conditions. 199 1.1.1.2 christos --long[=#] Enable long distance matching with window log #. [Default: 27] 200 1.1.1.2 christos --patch-from=REF Use REF as the reference point for Zstandard's diff engine. 201 1.1.1.2 christos 202 1.1.1.2 christos -T# Spawn # compression threads. [Default: 1; pass 0 for core count.] 203 1.1.1.2 christos --single-thread Share a single thread for I/O and compression (slightly different than `-T1`). 204 1.1.1.2 christos --auto-threads={physical|logical} 205 1.1.1.2 christos Use physical/logical cores when using `-T0`. [Default: Physical] 206 1.1.1.2 christos 207 1.1.1.2 christos -B# Set job size to #. [Default: 0 (automatic)] 208 1.1.1.2 christos --rsyncable Compress using a rsync-friendly method (`-B` sets block size). 209 1.1.1.2 christos 210 1.1.1.2 christos --exclude-compressed Only compress files that are not already compressed. 211 1.1.1.2 christos 212 1.1.1.2 christos --stream-size=# Specify size of streaming input from STDIN. 213 1.1.1.2 christos --size-hint=# Optimize compression parameters for streaming input of approximately size #. 214 1.1.1.2 christos --target-compressed-block-size=# 215 1.1.1.2 christos Generate compressed blocks of approximately # size. 216 1.1.1.2 christos 217 1.1.1.2 christos --no-dictID Don't write `dictID` into the header (dictionary compression only). 218 1.1.1.2 christos --[no-]compress-literals Force (un)compressed literals. 219 1.1.1.2 christos --[no-]row-match-finder Explicitly enable/disable the fast, row-based matchfinder for 220 1.1.1.2 christos the 'greedy', 'lazy', and 'lazy2' strategies. 221 1.1.1.2 christos 222 1.1.1.2 christos --format=zstd Compress files to the `.zst` format. [Default] 223 1.1.1.2 christos --[no-]mmap-dict Memory-map dictionary file rather than mallocing and loading all at once 224 1.1.1.2 christos --format=gzip Compress files to the `.gz` format. 225 1.1.1.2 christos --format=xz Compress files to the `.xz` format. 226 1.1.1.2 christos --format=lzma Compress files to the `.lzma` format. 227 1.1.1.2 christos --format=lz4 Compress files to the `.lz4` format. 228 1.1.1.2 christos 229 1.1.1.2 christos Advanced decompression options: 230 1.1.1.2 christos -l Print information about Zstandard-compressed files. 231 1.1.1.2 christos --test Test compressed file integrity. 232 1.1.1.2 christos -M# Set the memory usage limit to # megabytes. 233 1.1.1.2 christos --[no-]sparse Enable sparse mode. [Default: Enabled for files, disabled for STDOUT.] 234 1.1.1.2 christos --[no-]pass-through Pass through uncompressed files as-is. [Default: Disabled] 235 1.1.1.2 christos 236 1.1.1.2 christos Dictionary builder: 237 1.1.1.2 christos --train Create a dictionary from a training set of files. 238 1.1.1.2 christos 239 1.1.1.2 christos --train-cover[=k=#,d=#,steps=#,split=#,shrink[=#]] 240 1.1.1.2 christos Use the cover algorithm (with optional arguments). 241 1.1.1.2 christos --train-fastcover[=k=#,d=#,f=#,steps=#,split=#,accel=#,shrink[=#]] 242 1.1.1.2 christos Use the fast cover algorithm (with optional arguments). 243 1.1.1.2 christos 244 1.1.1.2 christos --train-legacy[=s=#] Use the legacy algorithm with selectivity #. [Default: 9] 245 1.1.1.2 christos -o NAME Use NAME as dictionary name. [Default: dictionary] 246 1.1.1.2 christos --maxdict=# Limit dictionary to specified size #. [Default: 112640] 247 1.1.1.2 christos --dictID=# Force dictionary ID to #. [Default: Random] 248 1.1.1.2 christos 249 1.1.1.2 christos Benchmark options: 250 1.1.1.2 christos -b# Perform benchmarking with compression level #. [Default: 3] 251 1.1.1.2 christos -e# Test all compression levels up to #; starting level is `-b#`. [Default: 1] 252 1.1.1.2 christos -i# Set the minimum evaluation to time # seconds. [Default: 3] 253 1.1.1.2 christos -B# Cut file into independent chunks of size #. [Default: No chunking] 254 1.1.1.2 christos -S Output one benchmark result per input file. [Default: Consolidated result] 255 1.1.1.2 christos -D dictionary Benchmark using dictionary 256 1.1.1.2 christos --priority=rt Set process priority to real-time. 257 1.1 christos ``` 258 1.1 christos 259 1.1 christos ### Passing parameters through Environment Variables 260 1.1 christos There is no "generic" way to pass "any kind of parameter" to `zstd` in a pass-through manner. 261 1.1 christos Using environment variables for this purpose has security implications. 262 1.1 christos Therefore, this avenue is intentionally restricted and only supports `ZSTD_CLEVEL` and `ZSTD_NBTHREADS`. 263 1.1 christos 264 1.1 christos `ZSTD_CLEVEL` can be used to modify the default compression level of `zstd` 265 1.1 christos (usually set to `3`) to another value between 1 and 19 (the "normal" range). 266 1.1 christos 267 1.1 christos `ZSTD_NBTHREADS` can be used to specify a number of threads 268 1.1 christos that `zstd` will use for compression, which by default is `1`. 269 1.1 christos This functionality only exists when `zstd` is compiled with multithread support. 270 1.1 christos `0` means "use as many threads as detected cpu cores on local system". 271 1.1 christos The max # of threads is capped at `ZSTDMT_NBWORKERS_MAX`, 272 1.1 christos which is either 64 in 32-bit mode, or 256 for 64-bit environments. 273 1.1 christos 274 1.1 christos This functionality can be useful when `zstd` CLI is invoked in a way that doesn't allow passing arguments. 275 1.1 christos One such scenario is `tar --zstd`. 276 1.1 christos As `ZSTD_CLEVEL` and `ZSTD_NBTHREADS` only replace the default compression level 277 1.1 christos and number of threads respectively, they can both be overridden by corresponding command line arguments: 278 1.1 christos `-#` for compression level and `-T#` for number of threads. 279 1.1 christos 280 1.1 christos 281 1.1 christos ### Long distance matching mode 282 1.1 christos The long distance matching mode, enabled with `--long`, is designed to improve 283 1.1 christos the compression ratio for files with long matches at a large distance (up to the 284 1.1 christos maximum window size, `128 MiB`) while still maintaining compression speed. 285 1.1 christos 286 1.1 christos Enabling this mode sets the window size to `128 MiB` and thus increases the memory 287 1.1 christos usage for both the compressor and decompressor. Performance in terms of speed is 288 1.1 christos dependent on long matches being found. Compression speed may degrade if few long 289 1.1 christos matches are found. Decompression speed usually improves when there are many long 290 1.1 christos distance matches. 291 1.1 christos 292 1.1 christos Below are graphs comparing the compression speed, compression ratio, and 293 1.1 christos decompression speed with and without long distance matching on an ideal use 294 1.1 christos case: a tar of four versions of clang (versions `3.4.1`, `3.4.2`, `3.5.0`, 295 1.1 christos `3.5.1`) with a total size of `244889600 B`. This is an ideal use case as there 296 1.1 christos are many long distance matches within the maximum window size of `128 MiB` (each 297 1.1 christos version is less than `128 MiB`). 298 1.1 christos 299 1.1 christos Compression Speed vs Ratio | Decompression Speed 300 1.1 christos ---------------------------|--------------------- 301 1.1 christos  |  302 1.1 christos 303 1.1 christos | Method | Compression ratio | Compression speed | Decompression speed | 304 1.1 christos |:-------|------------------:|-------------------------:|---------------------------:| 305 1.1 christos | `zstd -1` | `5.065` | `284.8 MB/s` | `759.3 MB/s` | 306 1.1 christos | `zstd -5` | `5.826` | `124.9 MB/s` | `674.0 MB/s` | 307 1.1 christos | `zstd -10` | `6.504` | `29.5 MB/s` | `771.3 MB/s` | 308 1.1 christos | `zstd -1 --long` | `17.426` | `220.6 MB/s` | `1638.4 MB/s` | 309 1.1 christos | `zstd -5 --long` | `19.661` | `165.5 MB/s` | `1530.6 MB/s` | 310 1.1 christos | `zstd -10 --long`| `21.949` | `75.6 MB/s` | `1632.6 MB/s` | 311 1.1 christos 312 1.1 christos On this file, the compression ratio improves significantly with minimal impact 313 1.1 christos on compression speed, and the decompression speed doubles. 314 1.1 christos 315 1.1 christos On the other extreme, compressing a file with few long distance matches (such as 316 1.1 christos the [Silesia compression corpus]) will likely lead to a deterioration in 317 1.1 christos compression speed (for lower levels) with minimal change in compression ratio. 318 1.1 christos 319 1.1 christos The below table illustrates this on the [Silesia compression corpus]. 320 1.1 christos 321 1.1 christos [Silesia compression corpus]: https://sun.aei.polsl.pl//~sdeor/index.php?page=silesia 322 1.1 christos 323 1.1 christos | Method | Compression ratio | Compression speed | Decompression speed | 324 1.1 christos |:-------|------------------:|------------------:|---------------------:| 325 1.1 christos | `zstd -1` | `2.878` | `231.7 MB/s` | `594.4 MB/s` | 326 1.1 christos | `zstd -1 --long` | `2.929` | `106.5 MB/s` | `517.9 MB/s` | 327 1.1 christos | `zstd -5` | `3.274` | `77.1 MB/s` | `464.2 MB/s` | 328 1.1 christos | `zstd -5 --long` | `3.319` | `51.7 MB/s` | `371.9 MB/s` | 329 1.1 christos | `zstd -10` | `3.523` | `16.4 MB/s` | `489.2 MB/s` | 330 1.1 christos | `zstd -10 --long`| `3.566` | `16.2 MB/s` | `415.7 MB/s` | 331 1.1 christos 332 1.1 christos 333 1.1 christos ### zstdgrep 334 1.1 christos 335 1.1 christos `zstdgrep` is a utility which makes it possible to `grep` directly a `.zst` compressed file. 336 1.1 christos It's used the same way as normal `grep`, for example : 337 1.1 christos `zstdgrep pattern file.zst` 338 1.1 christos 339 1.1 christos `zstdgrep` is _not_ compatible with dictionary compression. 340 1.1 christos 341 1.1 christos To search into a file compressed with a dictionary, 342 1.1 christos it's necessary to decompress it using `zstd` or `zstdcat`, 343 1.1 christos and then pipe the result to `grep`. For example : 344 1.1 christos `zstdcat -D dictionary -qc -- file.zst | grep pattern` 345