005_Linux压缩文件命令

  1. zip/unzip --- zip格式
压缩文件
root@ubuntu:~/Test# zip  Test.zip hello.c hello.c.hard
  adding: hello.c (deflated 12%)
  adding: hello.c.hard (deflated 12%)
root@ubuntu:~/Test# ls
hello.c  hello.c.hard  hello.c.hard1  hello.c.soft  shell  test  Test.zip
解压文件
root@ubuntu:~/Test# rm -rf hello.c hello.c.hard
root@ubuntu:~/Test# ls
hello.c.hard1  hello.c.soft  shell  test  Test.zip
root@ubuntu:~/Test# unzip Test.zip 
Archive:  Test.zip
  inflating: hello.c                 
  inflating: hello.c.hard            
  • 备注:如果zip -r ---代表递归子目录
  1. Linux最常用打包命令:tar(后缀一般为.tar.gz)
  • tar [option] 压缩包名 原材料
    • -c---压缩文件
    • -v---显示信息
    • -f---指定压缩包名
    • -z---gz格式格式压缩
压缩文件
root@ubuntu:~/Test# tar zcvf hello.tar.gz hello.c hello.c.hard
hello.c
hello.c.hard
root@ubuntu:~/Test# ls -l hello.tar.gz 
-rw-r--r-- 1 root root 217 12月 10 23:30 hello.tar.gz
解压文件
root@ubuntu:~/Test/test# ls
hello.tar.gz
root@ubuntu:~/Test/test# tar zxvf hello.tar.gz 
hello.c
hello.c.hard
root@ubuntu:~/Test/test# ls
hello.c  hello.c.hard  hello.tar.gz
原文地址:https://www.cnblogs.com/LittleFishC/p/14317208.html