gunzip
压缩与传输
用法
gunzip [-k] <file.gz>把 .gz 解开还原成原文件,成功后就删掉 .gz——想留着用 `-k`,同名文件已存在时得加 `-f`,而 `-c` 会把内容直接送到标准输出,一点也不落盘,和 zcat 一样。
常用选项
| 选项 | 含义 |
|---|---|
| -k | Keep the .gz file instead of removing it on success. |
| -c | Write to stdout and touch nothing on disk, the same as zcat. |
| -f | Overwrite an existing output file, which it otherwise refuses to do. |
| -t | Test the file instead of unpacking it. |
| -l | List the sizes inside. |
示例
gunzip backup.sql.gzLeaves backup.sql; the .gz file is removed.
gunzip -c dump.sql.gz | psql mydbRestore without ever writing the uncompressed file to disk.
打包和压缩是两件事:tar 打包,gzip 压小,.tar.gz 是两样一起。
怎么看
- 方括号 [ ] 表示这部分可以不写。
- 省略号 … 表示可以写多个。
- 选项区分大小写——有些命令里 -r 和 -R 不是一回事。
常见问题
Q. gunzip 是做什么的?
把 .gz 解开还原成原文件,成功后就删掉 .gz——想留着用 `-k`,同名文件已存在时得加 `-f`,而 `-c` 会把内容直接送到标准输出,一点也不落盘,和 zcat 一样。
Q. 怎么写?
gunzip [-k] <file.gz> —— 方括号表示可以省略的部分。
Q. 值得记的选项有几个?
这里列了 5 个,完整列表在 man gunzip。这条命令属于压缩与传输。
相关命令
man 手册: man gunzip