Linux下的压缩与解压缩
1 .gz
1)压缩
root@xiaohuang-virtual-machine:/home/xiaohuang/桌面/hellow/hellow# gzip 2.txt 3.txt root@xiaohuang-virtual-machine:/home/xiaohuang/桌面/hellow/hellow# ls -al 总用量 20 drwxr-xr-x 3 root root 4096 8月 30 19:11 . drwxr-xr-x 3 root root 4096 8月 30 19:05 .. -rw-r--r-- 1 root root 26 8月 30 19:05 2.txt.gz -rw-r--r-- 1 root root 26 8月 30 19:06 3.txt.gz drwxr-xr-x 2 root root 4096 8月 30 19:07 word root@xiaohuang-virtual-machine:/home/xiaohuang/桌面/hellow/hellow#
2)解压缩:
root@xiaohuang-virtual-machine:/home/xiaohuang/桌面/hellow/hellow# gzip -d 2.txt.gz 3.txt.gz root@xiaohuang-virtual-machine:/home/xiaohuang/桌面/hellow/hellow# ls -al 总用量 12 drwxr-xr-x 3 root root 4096 8月 30 19:12 . drwxr-xr-x 3 root root 4096 8月 30 19:05 .. -rw-r--r-- 1 root root 0 8月 30 19:05 2.txt -rw-r--r-- 1 root root 0 8月 30 19:06 3.txt drwxr-xr-x 2 root root 4096 8月 30 19:07 word root@xiaohuang-virtual-machine:/home/xiaohuang/桌面/hellow/hellow#
注意:不能压缩目录!支持批量压缩,源文件被替换成.gz结尾的文件。
2 .bz2
1)压缩
root@xiaohuang-virtual-machine:/home/xiaohuang/桌面/hellow/hellow# bzip2 2.txt 3.txt root@xiaohuang-virtual-machine:/home/xiaohuang/桌面/hellow/hellow# ls -al 总用量 20 drwxr-xr-x 3 root root 4096 8月 30 19:17 . drwxr-xr-x 3 root root 4096 8月 30 19:05 .. -rw-r--r-- 1 root root 14 8月 30 19:05 2.txt.bz2 -rw-r--r-- 1 root root 14 8月 30 19:06 3.txt.bz2 drwxr-xr-x 2 root root 4096 8月 30 19:07 word root@xiaohuang-virtual-machine:/home/xiaohuang/桌面/hellow/hellow#
2)解压缩:
root@xiaohuang-virtual-machine:/home/xiaohuang/桌面/hellow/hellow# bzip2 -d 2.txt.bz2 3.txt.bz2 root@xiaohuang-virtual-machine:/home/xiaohuang/桌面/hellow/hellow# ls -al 总用量 12 drwxr-xr-x 3 root root 4096 8月 30 19:17 . drwxr-xr-x 3 root root 4096 8月 30 19:05 .. -rw-r--r-- 1 root root 0 8月 30 19:05 2.txt -rw-r--r-- 1 root root 0 8月 30 19:06 3.txt drwxr-xr-x 2 root root 4096 8月 30 19:07 word root@xiaohuang-virtual-machine:/home/xiaohuang/桌面/hellow/hellow#
3)强制压缩:
root@xiaohuang-virtual-machine:/home/xiaohuang/桌面/hellow/hellow# bzip2 -z 2.txt 3.txt root@xiaohuang-virtual-machine:/home/xiaohuang/桌面/hellow/hellow# ls -alh 总用量 20K drwxr-xr-x 3 root root 4.0K 8月 30 19:23 . drwxr-xr-x 3 root root 4.0K 8月 30 19:05 .. -rw-r--r-- 1 root root 14 8月 30 19:05 2.txt.bz2 -rw-r--r-- 1 root root 14 8月 30 19:06 3.txt.bz2 drwxr-xr-x 2 root root 4.0K 8月 30 19:07 word root@xiaohuang-virtual-machine:/home/xiaohuang/桌面/hellow/hellow#
注意:不能压缩目录!支持批量压缩,源文件被替换成.bz2结尾的文件。
3 .zip
1)压缩
root@xiaohuang-virtual-machine:/home/xiaohuang/桌面/hellow# zip hellow 1.txt adding: 1.txt (stored 0%) root@xiaohuang-virtual-machine:/home/xiaohuang/桌面/hellow# ls -al 总用量 16 drwxr-xr-x 3 root root 4096 8月 30 19:27 . drwxr-xr-x 5 xiaohuang xiaohuang 4096 8月 30 19:03 .. -rw-r--r-- 1 root root 0 8月 30 19:04 1.txt drwxr-xr-x 3 root root 4096 8月 30 19:23 hellow -rw-r--r-- 1 root root 0 8月 30 19:04 hellow.py -rw-r--r-- 1 root root 160 8月 30 19:27 hellow.zip root@xiaohuang-virtual-machine:/home/xiaohuang/桌面/hellow#
2)解压缩
root@xiaohuang-virtual-machine:/home/xiaohuang/桌面/hellow# unzip hellow.zip Archive: hellow.zip extracting: 1.txt root@xiaohuang-virtual-machine:/home/xiaohuang/桌面/hellow# ls -al 总用量 12 drwxr-xr-x 2 root root 4096 8月 30 19:33 . drwxr-xr-x 5 xiaohuang xiaohuang 4096 8月 30 19:03 .. -rw-r--r-- 1 root root 0 8月 30 19:04 1.txt -rw-r--r-- 1 root root 0 8月 30 19:04 hellow.py -rw-r--r-- 1 root root 160 8月 30 19:27 hellow.zip root@xiaohuang-virtual-machine:/home/xiaohuang/桌面/hellow#
注意:可以压缩目录!支持批量压缩,源文件被替换成.zip结尾的文件。
4 tar
tar
-c 打包
-x 解包
-v 显示过程
-f 指定文件名
-t 查看包中的内容
1)打包
root@xiaohuang-virtual-machine:/home/xiaohuang/桌面/hellow# tar -cvf kangbazi.tar 1.txt hellow.py hellow.zip 1.txt hellow.py hellow.zip root@xiaohuang-virtual-machine:/home/xiaohuang/桌面/hellow# ls -al 总用量 24 drwxr-xr-x 2 root root 4096 8月 30 19:37 . drwxr-xr-x 5 xiaohuang xiaohuang 4096 8月 30 19:03 .. -rw-r--r-- 1 root root 0 8月 30 19:04 1.txt -rw-r--r-- 1 root root 0 8月 30 19:04 hellow.py -rw-r--r-- 1 root root 160 8月 30 19:27 hellow.zip -rw-r--r-- 1 root root 10240 8月 30 19:37 kangbazi.tar root@xiaohuang-virtual-machine:/home/xiaohuang/桌面/hellow#
2)解包
root@xiaohuang-virtual-machine:/home/xiaohuang/桌面/hellow# tar xvf kangbazi.tar 1.txt hellow.py hellow.zip root@xiaohuang-virtual-machine:/home/xiaohuang/桌面/hellow# ls -al 总用量 24 drwxr-xr-x 2 root root 4096 8月 30 19:40 . drwxr-xr-x 5 xiaohuang xiaohuang 4096 8月 30 19:03 .. -rw-r--r-- 1 root root 0 8月 30 19:04 1.txt -rw-r--r-- 1 root root 0 8月 30 19:04 hellow.py -rw-r--r-- 1 root root 160 8月 30 19:27 hellow.zip -rw-r--r-- 1 root root 10240 8月 30 19:37 kangbazi.tar root@xiaohuang-virtual-machine:/home/xiaohuang/桌面/hellow#
3)查看包里的内容
root@xiaohuang-virtual-machine:/home/xiaohuang/桌面/hellow# tar -tf kangbazi.tar 1.txt hellow.py hellow.zip root@xiaohuang-virtual-machine:/home/xiaohuang/桌面/hellow#
5.tar打包、压缩、解压缩
1) gz打包压缩
root@xiaohuang-virtual-machine:/home/xiaohuang/桌面/hellow# ls 1.txt hellow.py hellow.zip root@xiaohuang-virtual-machine:/home/xiaohuang/桌面/hellow# tar -zcvf kangbazi.tar.gz 1.txt hellow.py hellow.zip 1.txt hellow.py hellow.zip root@xiaohuang-virtual-machine:/home/xiaohuang/桌面/hellow# ls 1.txt hellow.py hellow.zip kangbazi.tar.gz root@xiaohuang-virtual-machine:/home/xiaohuang/桌面/hellow#
2) .gz解包解压缩
root@xiaohuang-virtual-machine:/home/xiaohuang/桌面/hellow# tar zxvf kangbazi.tar.gz 1.txt hellow.py hellow.zip root@xiaohuang-virtual-machine:/home/xiaohuang/桌面/hellow# ls 1.txt hellow.py hellow.zip kangbazi.tar.gz root@xiaohuang-virtual-machine:/home/xiaohuang/桌面/hellow#
3) .bz2打包压缩
root@xiaohuang-virtual-machine:/home/xiaohuang/桌面/hellow# tar -jzcf kangbazi.tar.bz2 1.txt hellow.py hellow.zip kangbazi.tar.gz root@xiaohuang-virtual-machine:/home/xiaohuang/桌面/hellow# ls 1.txt hellow.py hellow.zip kangbazi.tar.bz2 kangbazi1.tar.gz root@xiaohuang-virtual-machine:/home/xiaohuang/桌面/hellow#
4) .bz2解包解压缩
root@xiaohuang-virtual-machine:/home/xiaohuang/桌面# tar -jxvf kangbazi.tar.bz2 hellow/ hellow/kangbazi2.tar.bz2 root@xiaohuang-virtual-machine:/home/xiaohuang/桌面# ls hellow kangbazi.tar.bz2 linux pycharm-2018.2.2 pycharm-professional-2018.2.2.tar.gz root@xiaohuang-virtual-machine:/home/xiaohuang/桌面#
5) .xz打包压缩
root@xiaohuang-virtual-machine:/home/xiaohuang/桌面/hellow# tar -Jcvf kangbazi.tar.xz 1 kangbazi2.tar.bz2 1/ 1/1.txt kangbazi2.tar.bz2 root@xiaohuang-virtual-machine:/home/xiaohuang/桌面/hellow# ls 1 kangbazi2.tar.bz2 kangbazi.tar.xz root@xiaohuang-virtual-machine:/home/xiaohuang/桌面/hellow#
6) .xz解包解压缩
root@xiaohuang-virtual-machine:/home/xiaohuang/桌面/hellow# tar -Jxvf kangbazi.tar.xz 1/ 1/1.txt kangbazi2.tar.bz2 root@xiaohuang-virtual-machine:/home/xiaohuang/桌面/hellow# ls 1 kangbazi2.tar.bz2 kangbazi.tar.xz root@xiaohuang-virtual-machine:/home/xiaohuang/桌面/hellow#
Linux下的压缩与解压缩的更多相关文章
- Linux下的压缩zip,解压缩unzip命令详解及实例
实例:压缩服务器上当前目录的内容为xxx.zip文件 zip -r xxx.zip ./* 解压zip文件到当前目录 unzip filename.zip ====================== ...
- Linux下的压缩zip,解压缩unzip命令具体解释及实例
实例:压缩server上当前文件夹的内容为xxx.zip文件 zip -r xxx.zip ./* 解压zip文件到当前文件夹 unzip filename.zip ================= ...
- Linux下常用压缩、解压缩命令
常用的压缩工具 一是单纯的单文件压缩工具,主要有compress,gzip,bzip2. 二是打包压缩工具,也是最常用的,tar 压缩比:compress<gzip<bzip2 co ...
- Linux下的压缩解压缩命令详解
linux zip命令zip -r myfile.zip ./*将当前目录下的所有文件和文件夹全部压缩成myfile.zip文件,-r表示递归压缩子目录下所有文件. 2.unzipunzip -o - ...
- Linux下的压缩解压缩命令详解及实例
实例:压缩服务器上当前目录的内容为xxx.zip文件 zip -r xxx.zip ./* 解压zip文件到当前目录 unzip filename.zip ====================== ...
- Linux下的压缩解压缩
Linux下最常用的打包程序就是tar了,使用tar程序打出来的包我们常称为tar包,tar包文件的命令通常都是以.tar结尾的.生成tar包后,就可以用其它的程序来进 行压缩了,所以首先就来讲讲t ...
- Linux下的压缩和解压缩命令gzip/gunzip
作者:邓聪聪 Linux下的压缩和解压缩命令——gzip/gunzip yum -y install zip gzip (--安装压缩工具) gzip命令 gzip命令用来压缩文件.gzip是个使用广 ...
- Linux下的压缩(zip)解压(unzip)缩命令
.zip命令 zip -r myfile.zip ./* 将当前目录下的所有文件和文件夹全部压缩成myfile.zip文件,-r表示递归压缩子目录下所有文件. 2.unzip命令 unzip -o ...
- Linux下打包压缩war和解压war包 zip和jar
============jar================= 把当前目录下的所有文件打包成game.warjar -cvfM0 game.war ./ -c 创建war包-v 显示过程信息 ...
随机推荐
- BZOJ 1898 构造矩阵+矩阵快速幂
思路: T的最小公倍数是12 那么12以内暴力 整除12 的部分用矩阵快速幂 //By SiriusRen #include <cstdio> #include <cstring&g ...
- SSRS故障排除
1.SSRS部署到本地出现错误:为用户“Jimmy-PC\Jimmy”授予的权限不足,无法执行此操作.用户“Jimmy-PC\Jimmy”不具有所需的权限.请验证授予了足够的权限并且解决了 Windo ...
- 解决Mysql报错:PHP Warning: mysql_connect(): mysqlnd cannot connect to MySQL 4.1+ using the old insecure authentication.
最近我更新了appserv-win32-2.5.10的 PHP 5.2版本到PHP 5.3,在调用http://localhost/phpMyAdmin/时,出现如下错误:PHP Warning: ...
- label标签的可访问性问题
label标签可以优雅地扩大表单控件元素的点击区域.例如,单纯的单选框点击区域就鼻屎那么大的地方,经常会点不到位置.因此,label标签的使用对于提高页面的可用性可访问性是很有帮助的. 其实,它的样子 ...
- 第三方库requests
requests库 # 1.记得安装 第三方 模块 requests # pip install requests import requests url = 'http://www.baidu.co ...
- 【BZOJ4071】【APIO2015】巴邻旁之桥
题意: Description 一条东西走向的穆西河将巴邻旁市一分为二,分割成了区域 A 和区域 B. 每一块区域沿着河岸都建了恰好 1000000001 栋的建筑,每条岸边的建筑都从 0 编号到 1 ...
- 【BZOJ4448】【SCOI2015】情报传递
这题面错别字真tm多 题意: Description 奈特公司是一个巨大的情报公司,它有着庞大的情报网络.情报网络中共有n名情报员.每名情报员口J-能有若T名(可能没有)下线,除1名大头日外其余n-1 ...
- POJ 3134 Power Calculus (迭代剪枝搜索)
题目大意:略 题目里所有的运算都是幂运算,所以转化成指数的加减 由于搜索层数不会超过$2*log$层,所以用一个栈存储哪些数已经被组合出来了,不必暴力枚举哪些数已经被搜出来了 然后跑$iddfs$就行 ...
- kubernetes 项目
1:CI/CD Docker: Harbor Git Jenkins 2:微服务 istio
- HDU 4725 The Shortest Path in Nya Graph
he Shortest Path in Nya Graph Time Limit: 1000ms Memory Limit: 32768KB This problem will be judged o ...