Linux command
zcat 命令
文件
复制后可按需替换文件名、目录或参数。
常用示例
View contents
zcat [file.gz]
View contents of multiple
zcat [file1.gz] [file2.gz]
Pipe output
zcat [file.gz] | grep "[pattern]"
Display with line numbers
zcat [file.gz] | nl
Page through
zcat [file.gz] | less
Concatenate and decompress
zcat [file1.gz] [file2.gz] > [combined.txt]
说明
zcat decompresses gzip-compressed files and writes the uncompressed data to standard output, similar to cat for regular files. It is equivalent to gunzip -c or gzip -dc. zcat can decompress files created by gzip, zip, compress, or pack. It recognizes compressed files by their magic number, not just the .gz extension, allowing decompression of files with non-standard names. When reading from stdin, zcat will pass through data that is not in a recognized compressed format unchanged (acting like cat).
参数
- -f, --force
- Force decompression even if file has multiple links or the suffix does not match.
- -q, --quiet
- Suppress all warning messages.
- -v, --verbose
- Display filename and compression ratio for each file.
- -h, --help
- Display help message and exit.
- -V, --version
- Display version information and exit.
FAQ
What is the zcat command used for?
zcat decompresses gzip-compressed files and writes the uncompressed data to standard output, similar to cat for regular files. It is equivalent to gunzip -c or gzip -dc. zcat can decompress files created by gzip, zip, compress, or pack. It recognizes compressed files by their magic number, not just the .gz extension, allowing decompression of files with non-standard names. When reading from stdin, zcat will pass through data that is not in a recognized compressed format unchanged (acting like cat).
How do I run a basic zcat example?
Run `zcat [file.gz]` in a terminal, then adjust file names, paths, flags, or remote targets for your system.
What does -f, --force do in zcat?
Force decompression even if file has multiple links or the suffix does not match.