gzip

gzip *                          //压缩文件,并自动删除源文件。不支持直接压缩目录

gzip -rv 目录名           //递归的压缩目录

 下面是执行记录:

[[email protected] test]# ls -lrt
total 4
-rw-r--r--. 1 root root    0 Oct 24 12:14 aa.txt
drwxr-xr-x. 2 root root 4096 Oct 24 12:16 bb
[[email protected] test]# gzip *
gzip: bb is a directory -- ignored
[[email protected] test]# ll
total 8
-rw-r--r--. 1 root root   27 Oct 24 12:14 aa.txt.gz
drwxr-xr-x. 2 root root 4096 Oct 24 12:16 bb

由执行可知,压缩以后会生成一个 .gz 的文件,我们想要 .zip 的怎么办,那就使用 zip 命令。

zip

zip test.zip test                    //压缩 test 为 test.zip 文件

zip test.zip test | rm -rf test  //压缩失败,并删除了 test 文件

zip -m test.zip test               //压缩 test 为 test.zip 文件,并删除 test 文件

压缩文件并删除源文件 

相关文章:

  • 2022-01-25
  • 2022-03-08
  • 2022-12-23
  • 2021-12-15
  • 2021-11-21
  • 2021-08-07
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2021-12-31
  • 2021-12-28
  • 2022-03-08
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案