zoukankan      html  css  js  c++  java
  • gzip

    gzip -c 将输出写到标准输出上,并保留原文本

    gzip * : 把当前目录中的每个文件压缩成.gz文件

    [root@NB gzip]# ls
    mysql-bin.001712  mysql-bin.001712.tar  mysql-bin.001835.tar  zoom_x86_64.rpm
    [root@NB gzip]# gzip *
    [root@NB gzip]# ls
    mysql-bin.001712.gz      mysql-bin.001835.tar.gz
    mysql-bin.001712.tar.gz  zoom_x86_64.rpm.gz

    gzip -dv * :把目录中每个压缩的文件解压,并列出说细的信息

    [root@NB gzip]# gzip -dv *
    mysql-bin.001712.gz:     79.3% -- replaced with mysql-bin.001712
    mysql-bin.001712.tar.gz:     79.3% -- replaced with mysql-bin.001712.tar
    mysql-bin.001835.tar.gz:     78.6% -- replaced with mysql-bin.001835.tar
    zoom_x86_64.rpm.gz:      0.0% -- replaced with zoom_x86_64.rpm

    同样可以这样,把当前目录下的所有文件压缩成.gz 文件-v是显示所有的过程:

    [root@NB gzip]# gzip -v *
    mysql-bin.001712:     79.3% -- replaced with mysql-bin.001712.gz
    mysql-bin.001712.tar:     79.3% -- replaced with mysql-bin.001712.tar.gz
    mysql-bin.001835.tar:     78.6% -- replaced with mysql-bin.001835.tar.gz
    zoom_x86_64.rpm:      0.0% -- replaced with zoom_x86_64.rpm.gz

    gzip -l *:显示每个压缩文件的内容并不解压:

    [root@NB gzip]# gzip -l *
             compressed        uncompressed  ratio uncompressed_name
               11410830            54998926  79.3% mysql-bin.001712
               11411047            55009280  79.3% mysql-bin.001712.tar
                4405058            20602880  78.6% mysql-bin.001835.tar
               55545235            55568080   0.0% zoom_x86_64.rpm
               82772170           186179166  55.5% (totals)

     因为gzip只能单个文件的压缩,所以我们常会先用tar打包多个文件为一个文件,然后再用zip压缩:

    [root@NB gzip]# ls
    sql_lxsc
    [root@NB gzip]# tar -cvf sql_lxsc.tar sql_lxsc/
    [root@NB gzip]# ls
    sql_lxsc  sql_lxsc.tar
    [root@NB gzip]# gzip -v sql_lxsc.tar 
    sql_lxsc.tar:     83.8% -- replaced with sql_lxsc.tar.gz
    [root@NB gzip]# ls
    sql_lxsc  sql_lxsc.tar.gz
    [root@NB gzip]# file sql_lxsc.tar.gz 
    sql_lxsc.tar.gz: gzip compressed data, was "sql_lxsc.tar", from Unix, last modified: Sat Dec  3 17:31:39 2016
    当然没这么麻烦:
    [root@NB gzip]# ls
    sql_lxsc
    [root@NB gzip]# tar -czvf sql_lxsc.tar.gz sql_lxsc/
    [root@NB gzip]# ls
    sql_lxsc  sql_lxsc.tar.gz
    [root@NB gzip]# file sql_lxsc.tar.gz 
    sql_lxsc.tar.gz: gzip compressed data, from Unix, last modified: Sat Dec  3 17:34:10 2016
  • 相关阅读:
    085 Maximal Rectangle 最大矩形
    084 Largest Rectangle in Histogram 柱状图中最大的矩形
    083 Remove Duplicates from Sorted List 有序链表中删除重复的结点
    082 Remove Duplicates from Sorted List II 有序的链表删除重复的结点 II
    081 Search in Rotated Sorted Array II 搜索旋转排序数组 ||
    080 Remove Duplicates from Sorted Array II 从排序阵列中删除重复 II
    079 Word Search 单词搜索
    078 Subsets 子集
    bzoj2326: [HNOI2011]数学作业
    bzoj2152: 聪聪可可
  • 原文地址:https://www.cnblogs.com/bass6/p/6129137.html
Copyright © 2011-2022 走看看