zoukankan      html  css  js  c++  java
  • 【转载】linux 压缩和解压缩命令gz、tar、zip、bz2

      linux系统下压缩解压缩很让人头大,每次都要查命令。转载下方便以后查阅。原文信息如下:

    作者:capecape 
    来源:CSDN 
    原文:https://blog.csdn.net/capecape/article/details/78548723 

    -------------------------------------------------------------------------------------

    一、gzip

    压缩后的格式为:*.gz

    这种压缩方式不能保存原文件;且不能压缩目录

    命令举例:
    #压缩
    [root@localhost tmp]# gzip buodo
    [root@localhost tmp]# ls
    buodo.gz
    #解压
    [root@localhost tmp]# gunzip buodo.gz
    [root@localhost tmp]# ls
    buodo

    二、tar

    命令选项:
    -z(gzip) 用gzip来压缩/解压缩文件
    -j(bzip2) 用bzip2来压缩/解压缩文件
    -v(verbose) 详细报告tar处理的文件信息
    -c(create) 创建新的档案文件
    -x(extract) 解压缩文件或目录
    -f(file) 使用档案文件或设备,这个选项通常是必选的。

    命令举例:
    #压缩
    [root@localhost tmp]# tar -zvcf buodo.tar.gz buodo
    [root@localhost tmp]# tar -jvcf buodo.tar.bz2 buodo

    #解压
    [root@localhost tmp]# tar -zvxf buodo.tar.gz
    [root@localhost tmp]# tar -jvxf buodo.tar.bz2

    三、zip

    与gzip相比:1)可以压缩目录; 2)可以保留原文件;

    选项:

    -r(recursive) 递归压缩目录内的所有文件和目录

    命令举例:
    #压缩和解压文件
    [root@localhost tmp]# zip boduo.zip boduo
    [root@localhost tmp]# unzip boduo.zip

    #压缩和解压目录
    [root@localhost tmp]# zip -r Demo.zip Demo
    adding: Demo/ (stored 0%)
    adding: Demo/Test2/ (stored 0%)
    adding: Demo/Test1/ (stored 0%)
    adding: Demo/Test1/test4 (stored 0%)
    adding: Demo/test3 (stored 0%)
    [root@localhost tmp]# unzip Demo.zip
    Archive: Demo.zip
    creating: Demo/
    creating: Demo/Test2/
    creating: Demo/Test1/
    extracting: Demo/Test1/test4
    extracting: Demo/test3

    四、bzip2

    压缩后的格式:.bz2
    参数
    -k 产生压缩文件后保留原文件

    命令举例
    #压缩
    [root@localhost tmp]# bzip2 boduo
    [root@localhost tmp]# bzip2 -k boduo

    #解压
    [root@localhost tmp]# bunzip2 boduo.bz2

  • 相关阅读:
    网络基础知识复习
    JVM参数
    【csp模拟赛5】限制 (restrict.cpp)--数学
    【csp模拟赛5】加减法--宽搜维护联通快
    【csp模拟赛5】购物(shopping.cpp)--常规
    【csp模拟赛4】基站建设 (station.cpp)
    【csp模拟赛4】旅行计划 (travelling.cpp)--欧拉回路
    【csp模拟赛4】 珠江夜游 (cruise.cpp)-二分,贪心
    【分块入门1-9】--分块大法好
    【luoguP3243】[HNOI2015]菜肴制作--拓扑排序
  • 原文地址:https://www.cnblogs.com/moluoqishi/p/10837216.html
Copyright © 2011-2022 走看看