归档命令(4)——gzip

[root@localhost ~]# gzip –help
Usage: gzip [OPTION]… [FILE]…
Compress or uncompress FILEs (by default, compress FILES in-place).

Mandatory arguments to long options are mandatory for short options too.

  -c, --stdout      在标准输出上写,保持原始文件不变
  -d, --decompress  解压缩
  -f, --force       强制强制重写输出文件并压缩链接
  -h, --help        give this help
  -l, --list        列出压缩文件内容
  -L, --license     显示软件许可证
  -n, --no-name     不保存或恢复原始名称和时间戳
  -N, --name        保存或恢复原始名称和时间戳
  -q, --quiet       禁止所有警告
  -r, --recursive   在目录上递归地操作
  -S, --suffix=SUF  在压缩文件上使用后缀SUF
  -t, --test        测试压缩文件的完整性
  -v, --verbose     详细模式
  -V, --version     显示版本号
  -1, --fast        压缩更快
  -9, --best        压缩更好
--rsyncable   Make rsync-friendly archive

With no FILE, or when FILE is -, read standard input.

Report bugs to bug-gzip@gnu.org.

示例

gzip 压缩文件,并删除原始文件

siu@Darling ~/work $ ls
a  b  c  dir
siu@Darling ~/work $ gzip a
siu@Darling ~/work $ ls
a.gz  b  c  dir
siu@Darling ~/work $ 

gzip -v 压缩文件,并显示压缩信息

siu@Darling ~/work $ gzip -v b
b:     26.4% -- replaced with b.gz
siu@Darling ~/work $ ls
a.gz  b.gz  c  dir
gunzip  解压文件,gunzip == gzip -d

siu@Darling ~/work $ gunzip a.gz 
siu@Darling ~/work $ ls
a  b.gz  c  dir
zcat   不解压而显示压缩文件的内容

siu@Darling ~/work $ zcat b.gz 
Picture perfect memories scattered all around the floor
Reaching for the phone 'cause I can't fight it anymore
And I wonder if I ever cross your mind
For me it happens all the time
gunzip -c   解压文件到标准输出,也就是一解压就输出内容到屏幕,不改动文件

siu@Darling ~/work $ gunzip -c b.gz 
Picture perfect memories scattered all around the floor
Reaching for the phone 'cause I can't fight it anymore
And I wonder if I ever cross your mind
For me it happens all the time
gunzip -l   显示压缩和解压缩的信息,但并不执行解压缩

siu@Darling ~/work $ gunzip -l b.gz 
         compressed        uncompressed  ratio uncompressed_name
                154                 182  26.4% b
siu@Darling ~/work $ ls
a  b.gz  c  dir
gzip -9 -r   用压缩量最大的方式递归压缩目录中的文件

siu@Darling ~/work $ gzip -9 -r dir
siu@Darling ~/work $ ls
a  b.gz  c  dir
siu@Darling ~/work $ ls -l dir
总用量 12
-rw-r--r-- 1 siu siu 154  112 16:22 a.gz
-rw-r--r-- 1 siu siu 154  112 16:22 b.gz
-rw-r--r-- 1 siu siu 154  112 16:22 c.gz
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值