归档与压缩CLI Manual
$gzip
Compress or expand files using Lempel-Ziv coding (LZ77).
命令语法POSIX Standard
gzip [OPTIONS] [FILE...]在交互式终端沙盒中实时运行
无需安装的客户端实时仿真环境。
bash — terminal
AST Sandbox (Free)
概述与工作原理
`gzip` compresses individual files, replacing them with `.gz` extensions. It is the standard compression format across Linux for package distribution, web compression, and system log archiving.
常用参数与选项说明
| Flag / Option | Description |
|---|---|
| -d, --decompress | Decompress files (same as gunzip). |
| -k, --keep | Keep (do not delete) original input files during compression. |
| -9, --best | Use maximum compression ratio (slower). |
实际生产案例与代码范例
#1Compress a log file
gzip -k notes.txt && ls -l notes.txt*Compresses notes.txt to notes.txt.gz while preserving original notes.txt.