zoukankan      html  css  js  c++  java
  • 文档归档和解压缩

     
    1.compress 压缩完的后缀为 .Z
    1.安装方法 
    [root@test5 ~]# yum install ncompress -y

    2.常用参数

      2.1 gzip //直接解压缩
    1 [root@test5 opt]# ls
    2 compresstest
    3 [root@test5 opt]# compress compresstest
    4 [root@test5 opt]# ls
    5 compresstest.Z
    6 [root@test4 opt]# uncompress compresstest.Z
    7 [root@test4 opt]# ls
    8 compresstest

      2.2 -v //显示压缩完的比例

    1 [root@test4 opt]# compress -v compresstest
    2 compresstest: -- replaced with compresstest.Z Compression: 8.33%

      2.3 -c //保留原文件,使用时需要对压缩完的文件进行重定向

    1 [root@test4 opt]# compress -c -v compresstest > compresstest.Z
    2 [root@test4 opt]# ls
    3 compresstest compresstest.Z

    注:这种压缩算法比较老,现在很少用到了

    2.gzip 压缩完后缀为.gz
      1.这个压缩软件,默认已安装
      2.常用方法
        2.1gzip //直接压缩
    1 [root@test4 opt]# gzip gziptest
    2 [root@test4 opt]# ls
    3 gziptest.gz

        2.2-d //解压

    1 [root@test4 opt]# gzip -d gziptest.gz
    2 [root@test4 opt]# ls
    3 gziptest

        2.3 -v //显示压缩完的比例

    1 [root@test4 opt]# gzip -v gziptest
    2 gziptest: 8.6% -- replaced with gziptest.gz

        2.3 -c //保留原文件,使用时需要对压缩完的文件进行重定向

    1 [root@test4 opt]# gzip -cv gziptest > gziptest.gz
    2 gziptest: 8.6%
    3 [root@test4 opt]# ls
    4 gziptest gziptest.gz

        3.zcat //压缩完的文件可不解压,直接查看

    1 [root@test4 opt]# zcat gziptest.gz
    2 fasd
    3 dafs

    3.bzip2 压缩.bz2 使用方法和gzip一样,查看文件命令为bzcat,这两者的区别是,gzip压缩的速度快,但是bzip2的压缩率比较高。

    4.zip 压缩完后缀为 .zip
      1.默认已安装
      2.常用方法
        2.1 zip //压缩
    1 [root@test4 opt]# zip ziptest.zip ziptest
    2 adding: ziptest (stored 0%)
    3 [root@test4 opt]# ls
    4 ziptest ziptest.zip

        2.2 unzip //解压

    1 [root@test4 opt]# unzip ziptest.zip
    2 Archive: ziptest.zip
    3 extracting: ziptest
    4 [root@test4 opt]# ls
    5 ziptest ziptest.zip

    5.tar 归档功能,后缀名为.tar。本身没有解压缩的功能,只有将多个文件打包成一个文件功能,不过在这过程中,可以调用其它压缩工具。

    1.常用方法
      1.1 -c //创建一个打包文件 (create)
      1.2 -v //显示打包文件过程
      1.3 -f //指明打包完的文件名
      1.4 tar cvf
    1 [root@test4 opt]# tar cvf tartest.tar tartest
    2 tartest
    3 [root@test4 opt]# ls
    4 tartest tartest.tar

      1.5 --remove-files //不保留原文件

    1 [root@test4 opt]# tar cvf tartest.tar tartest --remove-files
    2 tartest
    3 [root@test4 opt]# ls
    4 tartest.tar

      1.6 -t //查看打包文件里包含的文件

    1 [root@test4 opt]# tar tf tartest.tar
    2 tartest

      1.7 -x //解档文件

    1 [root@test4 opt]# tar -xf tartest.tar
    2 [root@test4 opt]# ls
    3 tartest tartest.tar

      1.8 -C //指明解压路径

    1 [root@test4 opt]# tar -xf tartest.tar -C 11
    2 [root@test4 opt]# ll 11
    3 总计 4
    4 -rw-r--r-- 1 root root 0 01-17 00:00 tartest

    2.多个文件操作

      2.1 打包多个文件,需要注意,目录里是否有文件,没有文件的时候,打包需要注意。
    1 [root@test4 opt]# tar cvf tartest.tar tartest1 tartest2 tartest3
    2 tartest1
    3 tartest2
    4 tartest3
    5 [root@test4 opt]# ls
    6 tartest1 tartest2 tartest3 tartest.tar

      2.2 解压全部文件

    1 [root@test4 opt]# tar xvf tartest.tar
    2 tartest1
    3 tartest2
    4 tartest3

      2.3 解压单个文件

    1 [root@test4 opt]# tar xvf tartest.tar tartest1
    2 tartest1

      3.调用压缩软件 gzip或bzip2

        3.1.1 -z //调用gzip 后缀文件名为 .gz
    1 [root@test4 opt]# tar zcf tartest.gz *
    2 [root@test4 opt]# ls
    3 tartest1 tartest2 tartest3 tartest.gz

        3.1.2 -zx //解压打包文件。 解压一个文件之前,需要注意使用的压缩算法是什么。

    1 [root@test4 opt]# tar zxf tartest.gz
    2 [root@test4 opt]# ls
    3 tartest1 tartest2 tartest3 tartest.gz

        3.2.1 -j //调用 bzip2 后缀文件名为bz2

        使用方法和gzip一样
     
     
     
     
     
     
  • 相关阅读:
    二十六、oracle pl/sql 分页
    二十五、oracle pl/sql进阶--控制结构(分支,循环,控制)
    二十四、oracle pl/sql 变量
    python笔记之字典
    python笔记之元祖
    python笔记之列表
    python笔记之字符串
    python笔记之数据类型
    python笔记之python基础
    在windows系统电脑上同时安装python2.x和python3.x版本
  • 原文地址:https://www.cnblogs.com/sangmu/p/6648502.html
Copyright © 2011-2022 走看看