zoukankan      html  css  js  c++  java
  • 20190923-08Linux压缩和解压类 000 016

    gzip/gunzip 压缩

    1.基本语法

    gzip 文件 (功能描述:压缩文件,只能将文件压缩为*.gz文件)

    gunzip 文件.gz (功能描述:解压缩文件命令)

    2.经验技巧

    1只能压缩文件不能压缩目录

    2不保留原来的文件

    3.案例实操

    1gzip压缩

    [root@hadoop101 ~]# ls

    test.java

    [root@hadoop101 ~]# gzip houge.txt

    [root@hadoop101 ~]# ls

    houge.txt.gz

    2gunzip解压缩文件

    [root@hadoop101 ~]# gunzip houge.txt.gz

    [root@hadoop101 ~]# ls

    houge.txt

    zip/unzip 压缩

    1.基本语法

    zip  [选项] XXX.zip  将要压缩的内容 (功能描述:压缩文件和目录的命令)

    unzip [选项] XXX.zip (功能描述:解压缩文件)

    2.选项说明

    1-29

    zip选项

    功能

    -r

    压缩目录

    1-30

    unzip选项

    功能

    -d<目录>

    指定解压后文件的存放目录

    3.经验技巧

    zip 压缩命令在window/linux都通用,可以压缩目录且保留源文件

    4.案例实操

    1)压缩 1.txt 2.txt,压缩后的名称为mypackage.zip

    [root@hadoop101 opt]# touch bailongma.txt

    [root@hadoop101 ~]# zip houma.zip houge.txt bailongma.txt

      adding: houge.txt (stored 0%)

      adding: bailongma.txt (stored 0%)

    [root@hadoop101 opt]# ls

    houge.txt bailongma.txt houma.zip

    2)解压 mypackage.zip

    [root@hadoop101 ~]# unzip houma.zip

    Archive:  houma.zip

     extracting: houge.txt               

     extracting: bailongma.txt       

    [root@hadoop101 ~]# ls

    houge.txt bailongma.txt houma.zip

    3)解压mypackage.zip到指定目录-d

    [root@hadoop101 ~]# unzip houma.zip -d /opt

    [root@hadoop101 ~]# ls /opt/

    tar 打包

    1.基本语法

    tar  [选项]  XXX.tar.gz  将要打包进去的内容 (功能描述:打包目录,压缩后的文件格式.tar.gz

    2.选项说明

    1-31

    选项

    功能

    -z

    打包同时压缩

    -c

    产生.tar打包文件

    -v

    显示详细信息

    -f

    指定压缩后的文件名

    -x

    解包.tar文件

    3.案例实操

    1)压缩多个文件

    [root@hadoop101 opt]# tar -zcvf houma.tar.gz houge.txt bailongma.txt

    houge.txt

    bailongma.txt

    [root@hadoop101 opt]# ls

    houma.tar.gz houge.txt bailongma.txt

    2压缩目录

    [root@hadoop101 ~]# tar -zcvf xiyou.tar.gz xiyou/

    xiyou/

    xiyou/mingjie/

    xiyou/dssz/

    xiyou/dssz/houge.txt

    3)解压到当前目录

    [root@hadoop101 ~]# tar -zxvf houma.tar.gz

    4解压到指定目录

    [root@hadoop101 ~]# tar -zxvf xiyou.tar.gz -C /opt

    [root@hadoop101 ~]# ll /opt/

  • 相关阅读:
    你真的了解try{ return }finally{}中的return?
    js删除一个div
    js清空 input file上传文件控件
    获取配置文件数据库名称
    【转】一文搞定web自动化环境常见问题
    【转】使用SHC加密bash脚本程序以及解密
    【转】Python远程调试图文教程 之 Pycharm Remote Debug
    【转】Windows下安装MySQL详细教程
    将安装CentOS虚机的iso设置为yum源
    【算法】java语言求不定长字符串的最长子串和长度
  • 原文地址:https://www.cnblogs.com/YUJIE666/p/11570195.html
Copyright © 2011-2022 走看看