Linux文件压缩与解压命令
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文件压缩与解压命令的更多相关文章
- Linux 文件压缩与解压相关
tar [-cxtzjvfpPN] 文件与目录 .... 参数:-c :建立一个压缩文件的参数指令-x :解开一个压缩文件的参数指令 -t :查看压缩文件里面的文件 特别注意: c/x/t 同时只能存 ...
- Linux 下文件压缩与解压命令详解
tar 命令 -c 建立压缩档案 -x 解压 -t 查看内容 -r 向压缩归档文件末尾追加文件 -u 更新原压缩包中的文件 这五个是独立的命令,压缩解压都要用到其中一个,可以和别的命令连用但只能用其中 ...
- Linux文件压缩/打包/解压
在Linux日常维护中,经常需要备份同步一些比较重要的文件,而在传输过程中如果文件比较大往往会非常慢,而且还会非常占用空间,这时候就需要我们使用压缩工具对大文件进行压缩打包,下面我们来介绍一下常用的压 ...
- linux的 压缩与解压 命令集
bzip2压缩费时但效果好,而且支持hadoop的hdfs文件切分,gzip不行 bzip2 [-cdz] 文件名 -c :将压缩的过程输出到屏幕 -d :解压缩 -z :压缩 -# :压缩比的参数, ...
- Linux下压缩与解压命令tar
Linux下常见压缩文件的扩展名 *.gz:gzip压缩的: *.bz2:bzip2压缩的: *.tar:tar程序打包但没有压缩的: *.tar.gz:打包后并经过gzip压缩的: *.tar.bz ...
- 本地上传文件至服务器的技巧(linux文件压缩及解压文件)
linux(ubuntu)文件解压及压缩文件 ubuntu支持文件的解压及压缩功能, 如果ubuntu上面没有安装过unzip工具的话,可以通过下面命令安装: sudo apt-get install ...
- linux 文件压缩与解压
zip格式: zip -r(源文件是目录) [目标文件] [源文件] unzip -d [解压到的目录] [要解压的文件] gz格式: gzip [源文件] #会删除源文件 gzip -c [源文 ...
- linux 常用压缩、解压命令
.tar.gz 解压为 tar -zxvf xx.tar.gz 压缩为 tar -zcvf target.tar.gz ./src_dir zip 解压为 ...
- Linux之文件压缩与解压
文件压缩与解压 1.tar命令 tar命令可以为Linux的文件和目录创建档案. 利用tar,可以为某一特定文件创建档案(备份文件),也可以在档案中改变文件,或者向档案中加入新的文件.tar最初被用来 ...
随机推荐
- VS2013下配置OpenCV 3.0.0 &&& VS2013下配置Opencv2.4.9
最近做图像需要用到Matlab和OpenCV,一些东西真的是要深入的研究进去才会有所发现,但Matlab和C++都不是我擅长的语言,所以要很加油很加油才行啊!! 步入正题. 1. 环境:Win7 6 ...
- LACP链路聚合控制协议
LACP链路聚合控制协议 来源: https://www.cnblogs.com/taosim/articles/4378691.html http://storage.chinabyte.com/6 ...
- 看了就学会之React redux入门示例
环境准备 为了方便,这里使用create-react-app搭建react环境 create-react-app mydemo 弹出配置 如果需要自定义react的配置,需要运行下面的命令把配置文件弹 ...
- BZOJ[NOI2004]郁闷的出纳员 | Splay板子题
题目: 洛谷也能评测....还有我wa了10多次的记录233 题解: 不要想得太复杂,搞一个全局变量记录一下工资的改变量Delta,这样可以等询问的时候就输出val+Delta,然后插入的时候插入x- ...
- java反射调用私有方法和修改私有属性
//调用私有方法package com.java.test; public class PrivateMethod { private String sayHello(String name) { r ...
- Lesson10 Fianl and fellings
1)Revision History Date Issue Description Author 8/May/2015 1.0 Finish the WPF of our small game,sol ...
- 蓝萝卜blu netty3升netty4
老项目是netty3的,本来想直接改到netty5,但是netty5居然是只支持jdk1.7,很奇怪jdk1.6和jdk1.8都不行..为了兼容jdk1.6加上netty4本来和netty5就差别不大 ...
- codeforces gym/100814 humming distance (二进制位数比较)
Gym - 100814I I. Salem time limit per test 1 second memory limit per test 1024 megabytes input stand ...
- Cocos2d-x中图字原理之深入分析
http://cache.baiducontent.com/c?m=9d78d513d9921cfe05ac94281a16a632451294247c89df4f3992d15f9217465c02 ...
- 将本地访问ip映射成域名
通过修改以下地址 C:\WINDOWS\system32\drivers\etc\hosts 加进你自己的如: 192.168.1.101 www.helloworld.com 配置nginx代理u ...