美文网首页
zip压缩工具、tar打包、tar打包并压缩

zip压缩工具、tar打包、tar打包并压缩

作者: 强出头 | 来源:发表于2018-01-10 17:15 被阅读0次

    65 zip压缩工具

    支持压缩目录

    默认不支持解压windows下的rar文件

    压缩、解压缩文件

    [root@localhost d6z]# yum install -y zip
    [root@localhost d6z]# ls
    1.txt  1.txt.xz  2.txt
    [root@localhost d6z]# zip 1.txt.zip 1.txt
      adding: 1.txt (deflated 75%)
    [root@localhost d6z]# ls
    1.txt  1.txt.xz  1.txt.zip  2.txt
    [root@localhost d6z]# yum install -y unzip
    [root@localhost d6z]# unzip 1.txt.zip 
    Archive:  1.txt.zip
    replace 1.txt? [y]es, [n]o, [A]ll, [N]one, [r]ename: y
      inflating: 1.txt                   
    [root@localhost d6z]# ls
    1.txt  1.txt.xz  1.txt.zip  2.txt
    [root@localhost d6z]# unzip 1.txt.zip -d /root/(不能指定名字)
    Archive:  1.txt.zip
      inflating: /root/1.txt             
    [root@localhost d6z]# ls /root/
    1.txt  anaconda-ks.cfg  d6z
    

    压缩、解压缩目录

    [root@localhost ~]# zip -r  d6z.zip d6z/
      adding: d6z/ (stored 0%)
      adding: d6z/1.txt.xz (deflated 0%)
      adding: d6z/2.txt (deflated 75%)
      adding: d6z/1.txt.zip (stored 0%)
      adding: d6z/1.txt (deflated 75%)
    [root@localhost ~]# ls -lh
    总用量 216K
    -rw-------. 1 root root 1.4K 12月 26 08:11 anaconda-ks.cfg
    drwxr-xr-x. 2 root root   65 1月  10 11:06 d6z
    -rw-r--r--. 1 root root 209K 1月  10 11:24 d6z.zip
    [root@localhost ~]# unzip -l d6z.zip 
    Archive:  d6z.zip
      Length      Date    Time    Name
    ---------  ---------- -----   ----
            0  01-10-2018 11:06   d6z/
        48652  01-10-2018 10:53   d6z/1.txt.xz
       215592  01-10-2018 10:53   d6z/2.txt
        54725  01-10-2018 11:00   d6z/1.txt.zip
       215592  01-10-2018 09:55   d6z/1.txt
    ---------                     -------
       534561                     5 files
    [root@localhost ~]# unzip d6z.zip 
    Archive:  d6z.zip
    replace d6z/1.txt.xz? [y]es, [n]o, [A]ll, [N]one, [r]ename: A
      inflating: d6z/1.txt.xz            
      inflating: d6z/2.txt               
     extracting: d6z/1.txt.zip           
      inflating: d6z/1.txt  
    [root@localhost ~]# unzip d6z.zip -d ./d6z/
    Archive:  d6z.zip
       creating: ./d6z/d6z/
      inflating: ./d6z/d6z/1.txt.xz      
      inflating: ./d6z/d6z/2.txt         
     extracting: ./d6z/d6z/1.txt.zip     
      inflating: ./d6z/d6z/1.txt         
    [root@localhost ~]# ls ./d6z
    1.txt  1.txt.xz  1.txt.zip  2.txt  d6z
    

    压缩、解压缩原文件不删除

    66 tar打包

    tar打包工具
    [root@localhost ~]# tar -cvf d6z.tar /root/d6z/(压缩)
    tar: 从成员名中删除开头的“/”
    /root/d6z/
    /root/d6z/1.txt.xz
    /root/d6z/2.txt
    /root/d6z/1.txt.zip
    /root/d6z/1.txt
    /root/d6z/d6z/
    /root/d6z/d6z/1.txt.xz
    /root/d6z/d6z/2.txt
    /root/d6z/d6z/1.txt.zip
    /root/d6z/d6z/1.txt
    /root/d6z/d6z.zip
    [root@localhost ~]# ls
    anaconda-ks.cfg  d6z  d6z.tar
    [root@localhost ~]# tar -xvf d6z.tar (解压)
    root/d6z/
    root/d6z/1.txt.xz
    root/d6z/2.txt
    root/d6z/1.txt.zip
    root/d6z/1.txt
    root/d6z/d6z/
    root/d6z/d6z/1.txt.xz
    root/d6z/d6z/2.txt
    root/d6z/d6z/1.txt.zip
    root/d6z/d6z/1.txt
    root/d6z/d6z.zip
    [root@localhost ~]# tar -tf d6z.tar (列出打包的目录)
    root/d6z/
    root/d6z/1.txt.xz
    root/d6z/2.txt
    root/d6z/1.txt.zip
    root/d6z/1.txt
    root/d6z/d6z/
    root/d6z/d6z/1.txt.xz
    root/d6z/d6z/2.txt
    root/d6z/d6z/1.txt.zip
    root/d6z/d6z/1.txt
    root/d6z/d6z.zip
    [root@localhost ~]# ls d6z/
    1.txt  1.txt.xz  1.txt.zip  2.txt  d6z  d6z.zip
    [root@localhost ~]# tar -cvf d6z.tar --exclude *.zip ./d6z/(过滤掉zip文件,可以多个过滤)
    ./d6z/
    ./d6z/1.txt.xz
    ./d6z/2.txt
    ./d6z/1.txt
    ./d6z/d6z/
    ./d6z/d6z/1.txt.xz
    ./d6z/d6z/2.txt
    ./d6z/d6z/1.txt
    [root@localhost ~]# tar -tf d6z.tar 
    ./d6z/
    ./d6z/1.txt.xz
    ./d6z/2.txt
    ./d6z/1.txt
    ./d6z/d6z/
    ./d6z/d6z/1.txt.xz
    ./d6z/d6z/2.txt
    ./d6z/d6z/1.txt
    

    67 tar打包并压缩

    tar打包并压缩

    zip打包压缩

    [root@localhost ~]# tar -zcvf d6z.tar.gz d6z/
    d6z/
    d6z/d6z/
    d6z/d6z/1.txt.xz
    d6z/d6z/2.txt
    d6z/d6z/1.txt.zip
    d6z/d6z/1.txt
    d6z/1.txt.xz
    d6z/2.txt
    d6z/1.txt.zip
    d6z/1.txt
    d6z/d6z.zip
    [root@localhost ~]# file d6z.tar.gz 
    d6z.tar.gz: gzip compressed data, from Unix, last modified: Wed Jan 10 17:14:14 2018
    [root@localhost ~]# tar -zxvf d6z.tar.gz 
    d6z/
    d6z/d6z/
    d6z/d6z/1.txt.xz
    d6z/d6z/2.txt
    d6z/d6z/1.txt.zip
    d6z/d6z/1.txt
    d6z/1.txt.xz
    d6z/2.txt
    d6z/1.txt.zip
    d6z/1.txt
    d6z/d6z.zip
    

    看下这个帖子: http://ask.apelearn.com/question/5435

    相关文章

      网友评论

          本文标题:zip压缩工具、tar打包、tar打包并压缩

          本文链接:https://www.haomeiwen.com/subject/hoannxtx.html