Linux - gzip使用

gzip命令使用

gzip通常用于文件压缩,但是不能压缩文件夹,并且压缩完原文件不保留

  • gzip 压缩:gzip xxxx.txt
[root@localhost home]# ls
abc.txt  admin  client  ClientM.c
//压缩ClientM.c文件
[root@localhost home]# gzip ClientM.c
//压缩为ClientM.c.gz
[root@localhost home]# ll
-rw-r--r-- 1 root  root     12 Aug 30 22:42 abc.txt
drwx------ 3 admin admin    92 May 14 02:27 admin
-rwxr-xr-x 1 root  root  17472 Aug 30 18:14 client
-rw-r--r-- 1 root  root   8668 Aug 30 10:10 ClientM.c.gz
[root@localhost home]#
  • gzip 压缩:gzip -v xxxx.txt( -v 显示过程)
[root@localhost home]# gzip -v ClientM.c
ClientM.c:       76.8% -- replaced with ClientM.c.gz
[root@localhost home]#
  • gzip递归压缩:gzip -r /home/*( -r 递归压缩)
[root@localhost home]# gzip -r tmp/*
[root@localhost home]# cd tmp/
[root@localhost tmp]# ll
total 24
-rw-r--r-- 1 root root   32 Aug 31 01:01 abc.txt.gz
-rwxr-xr-x 1 root root 6076 Aug 31 01:01 client.gz
-rw-r--r-- 1 root root 8668 Aug 31 01:01 ClientM.c.gz
[root@localhost tmp]#
  • gzip 解压:gzip -d xxx.gz( -v 显示过程)
[root@localhost home]# gzip -dv ClientM.c.gz
ClientM.c.gz:    76.8% -- replaced with ClientM.c
[root@localhost home]#
  • gzip 递归解压:gzip -rd xxx.gz( -v 显示过程)
[root@localhost home]# gzip -rd tmp/
[root@localhost home]# ll tmp/
total 64
-rw-r--r-- 1 root root    12 Aug 31 01:01 abc.txt
-rwxr-xr-x 1 root root 17472 Aug 31 01:01 client
-rw-r--r-- 1 root root 37204 Aug 31 01:01 ClientM.c
[root@localhost home]#

转载 : https://blog.csdn.net/weixin_43056298/article/details/100162000

上一篇:Linux - gzip常用语句


下一篇:2021-01-12