1  .zip 格式压缩与解压

压缩命令

zip  压缩文件名  源文件

zip  -r   压缩目录名       源目录

解压命令

unzip  文件名

td@td-Lenovo-IdeaPad-Y410P:~$ touch abc
td@td-Lenovo-IdeaPad-Y410P:~$ zip abc.zip abc
adding: abc (stored 0%)
td@td-Lenovo-IdeaPad-Y410P:~$ ls
abc examples.desktop workspace 模板 图片 下载 桌面
abc.zip sougou_64.deb 公共的 视频 文档 音乐
td@td-Lenovo-IdeaPad-Y410P:~$ mkdir -r japan
mkdir:无效选项 -- r
Try 'mkdir --help' for more information.
td@td-Lenovo-IdeaPad-Y410P:~$ mkdir japan
td@td-Lenovo-IdeaPad-Y410P:~$ ls
abc examples.desktop sougou_64.deb 公共的 视频 文档 音乐
abc.zip japan workspace 模板 图片 下载 桌面
td@td-Lenovo-IdeaPad-Y410P:~$ zip japan.zip japan
adding: japan/ (stored 0%)
td@td-Lenovo-IdeaPad-Y410P:~$ ls
abc examples.desktop japan.zip workspace 模板 图片 下载 桌面
abc.zip japan sougou_64.deb 公共的 视频 文档 音乐
td@td-Lenovo-IdeaPad-Y410P:~$ rm -r japan
td@td-Lenovo-IdeaPad-Y410P:~$ unzip japan.zip
Archive: japan.zip
creating: japan/
td@td-Lenovo-IdeaPad-Y410P:~$ ls
abc examples.desktop japan.zip workspace 模板 图片 下载 桌面
abc.zip japan sougou_64.deb 公共的 视频 文档 音乐
td@td-Lenovo-IdeaPad-Y410P:~$ rm abc
td@td-Lenovo-IdeaPad-Y410P:~$ unzip abc.zip
Archive: abc.zip
extracting: abc
td@td-Lenovo-IdeaPad-Y410P:~$ ls
abc examples.desktop japan.zip workspace 模板 图片 下载 桌面
abc.zip japan sougou_64.deb 公共的 视频 文档 音乐

.zip压缩格式既可以压缩文件也可以压缩目录

2 .gz格式压缩与解压

压缩

  gzip  源文件     #注意,压缩成.gz格式后源文件会消失

  gzip  -r   源目录    #注意,gzip压缩的目录不能打包,它压缩的是目录里面的子文件,不压缩目录

解压

  gzip  -d   压缩文件

  gunzip    压缩文件

td@td-Lenovo-IdeaPad-Y410P:~$ ls
examples.desktop workspace 模板 图片 下载 桌面
sougou_64.deb 公共的 视频 文档 音乐
td@td-Lenovo-IdeaPad-Y410P:~$ touch abc
td@td-Lenovo-IdeaPad-Y410P:~$ gzip abc
td@td-Lenovo-IdeaPad-Y410P:~$ ls
abc.gz sougou_64.deb 公共的 视频 文档 音乐
examples.desktop workspace 模板 图片 下载 桌面
td@td-Lenovo-IdeaPad-Y410P:~$ gzip -d abc.gz
td@td-Lenovo-IdeaPad-Y410P:~$ ls
abc sougou_64.deb 公共的 视频 文档 音乐
examples.desktop workspace 模板 图片 下载 桌面
td@td-Lenovo-IdeaPad-Y410P:~$ mkdir japan
td@td-Lenovo-IdeaPad-Y410P:~$ gzip -r japan
td@td-Lenovo-IdeaPad-Y410P:~$ ls
abc japan workspace 模板 图片 下载 桌面
examples.desktop sougou_64.deb 公共的 视频 文档 音乐
td@td-Lenovo-IdeaPad-Y410P:~$ touch japan/cangls japan/boduols
td@td-Lenovo-IdeaPad-Y410P:~$ gzip -r japan
td@td-Lenovo-IdeaPad-Y410P:~$ cd japan
td@td-Lenovo-IdeaPad-Y410P:~/japan$ ls
boduols.gz cangls.gz
td@td-Lenovo-IdeaPad-Y410P:~/japan$ cd
td@td-Lenovo-IdeaPad-Y410P:~$ gunzip japan
gzip: japan is a directory -- ignored
td@td-Lenovo-IdeaPad-Y410P:~$ gunzip -r japan
td@td-Lenovo-IdeaPad-Y410P:~$ ls
abc japan workspace 模板 图片 下载 桌面
examples.desktop sougou_64.deb 公共的 视频 文档 音乐
td@td-Lenovo-IdeaPad-Y410P:~$ cd japan
td@td-Lenovo-IdeaPad-Y410P:~/japan$ ls
boduols cangls
td@td-Lenovo-IdeaPad-Y410P:~/japan$

3.  .bz2压缩格式

压缩

  bzip2  源文件     #压缩后不保留源文件

  bzip2  -k   源文件    #压缩后保留源文件

#注意 bzip不可以压缩目录

解压

  bzip  -d   解压文件   #解压缩,-k保留源文件

bunzip2   解压文件   #解压缩,-k保留源文件

td@td-Lenovo-IdeaPad-Y410P:~$ touch abc
td@td-Lenovo-IdeaPad-Y410P:~$ bzip2 abc
td@td-Lenovo-IdeaPad-Y410P:~$ ls
abc.bz2 sougou_64.deb 公共的 视频 文档 音乐
examples.desktop workspace 模板 图片 下载 桌面
td@td-Lenovo-IdeaPad-Y410P:~$ bunzip2 abc.zip
bunzip2: Can't open input file abc.zip: No such file or directory.
td@td-Lenovo-IdeaPad-Y410P:~$ bunzip2 abc.bz2
td@td-Lenovo-IdeaPad-Y410P:~$ ls
abc sougou_64.deb 公共的 视频 文档 音乐
examples.desktop workspace 模板 图片 下载 桌面
td@td-Lenovo-IdeaPad-Y410P:~$ bzip2 -k abc
td@td-Lenovo-IdeaPad-Y410P:~$ ls
abc examples.desktop workspace 模板 图片 下载 桌面
abc.bz2 sougou_64.deb 公共的 视频 文档 音乐
td@td-Lenovo-IdeaPad-Y410P:~$ rm abc
td@td-Lenovo-IdeaPad-Y410P:~$ bzip2 -dk abc.bz2
td@td-Lenovo-IdeaPad-Y410P:~$ ls
abc examples.desktop workspace 模板 图片 下载 桌

4 tar 打包和解包命令

打包命令

  tar  -cvf   打包文件名    源文件

选项:

  -c   打包

  -v  显示打包过程

  -f  指定打包后的文件名

td@td-Lenovo-IdeaPad-Y410P:~$ tar -cvf japan.tar japan
japan/
japan/boduols
japan/cangls
td@td-Lenovo-IdeaPad-Y410P:~$ ls
abc.bz2 japan sougou_64.deb 公共的 视频 文档 音乐
examples.desktop japan.tar workspace

由于.gz和.bz2格式在目录压缩上不足,所以可以先将文件见打包,然后再压缩。

td@td-Lenovo-IdeaPad-Y410P:~$ gzip japan.tar
td@td-Lenovo-IdeaPad-Y410P:~$ ls
abc.bz2 japan sougou_64.deb 公共的 视频 文档 音乐
examples.desktop japan.tar.gz workspace 模板 图片 下载 桌面

解包命令

  tar  -xvf    打包文件名

 选项:

  -x 表示解包

td@td-Lenovo-IdeaPad-Y410P:~$ tar -cvf japan.tar japan
japan/
japan/boduols
japan/cangls
td@td-Lenovo-IdeaPad-Y410P:~$ tar -xvf japan.tar
japan/
japan/boduols
japan/cangls
td@td-Lenovo-IdeaPad-Y410P:~$ ls
examples.desktop japan.tar workspace 模板 图片 下载 桌面
japan sougou_64.deb 公共的 视频 文档 音乐

5   .tar.gz格式

其实.tar.gz格式是先打包为.tar格式,然后在压缩为.gz格式

压缩

  tar -zcvf  压缩包名.tar.gz   源文件

选项:

  -z  表示压缩为.tar.gz格式

解压

  tar -zxcf  压缩包.tar.gz 
选项:

  -x  解压.tar.gz文件

td@td-Lenovo-IdeaPad-Y410P:~$ tar -zcvf japan.tar.gz japan
japan/
japan/boduols
japan/cangls
td@td-Lenovo-IdeaPad-Y410P:~$ ls
examples.desktop japan.tar sougou_64.deb 公共的 视频 文档 音乐
japan japan.tar.gz workspace 模板 图片 下载 桌面
td@td-Lenovo-IdeaPad-Y410P:~$ tar -zxvf japan.tar.gz
japan/
japan/boduols
japan/cangls
td@td-Lenovo-IdeaPad-Y410P:~$ ls
examples.desktop japan.tar sougou_64.deb 公共的 视频 文档 音乐
japan japan.tar.gz workspace 模板 图片 下载 桌面

6  .tar.bz2 格式文件

压缩

  tar  -jcvf  压缩包名.tar.bz2  源文件

选项

  -j  压缩为.tar.bz2文件

解压

  tar -jxcf  压缩包.tar.bz2

td@td-Lenovo-IdeaPad-Y410P:~$ tar -jcvf japan.tar.bz2 japan
japan/
japan/boduols
japan/cangls
td@td-Lenovo-IdeaPad-Y410P:~$ ls
examples.desktop japan.tar.bz2 workspace 视频 下载
japan japan.tar.gz 公共的 图片 音乐
japan.tar sougou_64.deb 模板 文档 桌面
td@td-Lenovo-IdeaPad-Y410P:~$ rm -rf japan
td@td-Lenovo-IdeaPad-Y410P:~$ tar -jcvf japan.tar.bz2
tar: 谨慎地拒绝创建空归档文件
Try 'tar --help' or 'tar --usage' for more information.
td@td-Lenovo-IdeaPad-Y410P:~$ tar -jxvf japan.tar.bz2
japan/
japan/boduols
japan/cangls
td@td-Lenovo-IdeaPad-Y410P:~$ ls
examples.desktop japan.tar.bz2 workspace 视频 下载
japan japan.tar.gz 公共的 图片 音乐
japan.tar sougou_64.deb 模板 文档 桌面

Linux文件压缩与解压命令的更多相关文章

  1. Linux 文件压缩与解压相关

    tar [-cxtzjvfpPN] 文件与目录 .... 参数:-c :建立一个压缩文件的参数指令-x :解开一个压缩文件的参数指令 -t :查看压缩文件里面的文件 特别注意: c/x/t 同时只能存 ...

  2. Linux 下文件压缩与解压命令详解

    tar 命令 -c 建立压缩档案 -x 解压 -t 查看内容 -r 向压缩归档文件末尾追加文件 -u 更新原压缩包中的文件 这五个是独立的命令,压缩解压都要用到其中一个,可以和别的命令连用但只能用其中 ...

  3. Linux文件压缩/打包/解压

    在Linux日常维护中,经常需要备份同步一些比较重要的文件,而在传输过程中如果文件比较大往往会非常慢,而且还会非常占用空间,这时候就需要我们使用压缩工具对大文件进行压缩打包,下面我们来介绍一下常用的压 ...

  4. linux的 压缩与解压 命令集

    bzip2压缩费时但效果好,而且支持hadoop的hdfs文件切分,gzip不行 bzip2 [-cdz] 文件名 -c :将压缩的过程输出到屏幕 -d :解压缩 -z :压缩 -# :压缩比的参数, ...

  5. Linux下压缩与解压命令tar

    Linux下常见压缩文件的扩展名 *.gz:gzip压缩的: *.bz2:bzip2压缩的: *.tar:tar程序打包但没有压缩的: *.tar.gz:打包后并经过gzip压缩的: *.tar.bz ...

  6. 本地上传文件至服务器的技巧(linux文件压缩及解压文件)

    linux(ubuntu)文件解压及压缩文件 ubuntu支持文件的解压及压缩功能, 如果ubuntu上面没有安装过unzip工具的话,可以通过下面命令安装: sudo apt-get install ...

  7. linux 文件压缩与解压

    zip格式: zip -r(源文件是目录) [目标文件] [源文件] unzip -d [解压到的目录] [要解压的文件] gz格式: gzip [源文件]   #会删除源文件 gzip -c [源文 ...

  8. linux 常用压缩、解压命令

    .tar.gz     解压为          tar   -zxvf   xx.tar.gz    压缩为 tar -zcvf  target.tar.gz ./src_dir zip 解压为   ...

  9. Linux之文件压缩与解压

    文件压缩与解压 1.tar命令 tar命令可以为Linux的文件和目录创建档案. 利用tar,可以为某一特定文件创建档案(备份文件),也可以在档案中改变文件,或者向档案中加入新的文件.tar最初被用来 ...

随机推荐

  1. Visual Studio2015 、2017中如何支持MYSQL数据源

    原文:Visual Studio2015 .2017中如何支持MYSQL数据源 版权声明:本文为博主原创文章,未经博主允许不得转载. https://blog.csdn.net/ght886/arti ...

  2. 我与0xc000007b奋斗的日子

    自从新换了一台笔记本,就开始重装各种软件,就在将要开始软工课设的重要的日子里,我默默地在运行客户端时出现了一个这样的错误: 鉴于本人很废柴,自然不可能去查内存,所以开始各种度娘必应和谷歌,哦!原来应该 ...

  3. 【PHP】- 启用CRUL和GD

    1.修改php.ini文件,确保extension_dir配置为php目录的ext,如图: 2.修改php.ini文件,将以下两项取消注释: 3.将php目录下的 libeay32.dll 和 lib ...

  4. CSS使用示例

    CSS的存在就是将网页的内容与内容展示的方式进行了分离. 使用CSS的方式有好几种,最常用的是通过引入外部CSS文件进行使用 HTML <!DOCTYPE html> <html&g ...

  5. 【BestCoder #45】

    用家里的电脑来编程,各种不算 一开始15分钟刷掉T1和T2,然后就永远地卡在了T3... 后来看题解,傻了眼... 它强调的“只有一个答案”我还以为这是在提示我二分答案,于是我一直往权值线段树那个方向 ...

  6. Spring bean 创建过程源码解析

    在上一篇文件 Spring 中 bean 注册的源码解析 中分析了 Spring 中 bean 的注册过程,就是把配置文件中配置的 bean 的信息加载到内存中,以 BeanDefinition 对象 ...

  7. 利用MapReduce计算平均数

    利用mapreduce求出股票价格的开盘和收盘平均数 下图为采集到的股票信息,共计1416支股票的信息 因为在linux系统下默认采用utf-8的编码格式,而在win下txt默认采用ANSI编码格式. ...

  8. Installing patches on an ESXi 5.x by the command

    Purpose This article outlines the procedure for installing patches on an ESXi 5.x host from the comm ...

  9. 关于#include <bits/stdc++.h>

    经常看人写#include <bits/stdc++.h>却不知道是干啥的? #include<bits/stdc++.h>包含了目前c++所包含的所有头文件 对比: #inc ...

  10. shell编程学习笔记【原创】

    本文为本人学习笔记,如有转载请注明出处,谢谢 一.Bourne Shell 有如下四种变量: 用户自定义变量 位置变量,即命令行参数 预定义变量 环境变量 二.位置变量 $ 与键入的命令行一样,包含脚 ...