Linux学习之文件的压缩与解压

下面来学习四个常用的压缩命令。
gzip
特点:
1.只能压缩文件,不能压缩目录
2.不保留源文件
 
[root@localhost test]# gzip aaa             将aaa文件进行压缩
[root@localhost test]# gunzip aaa.gz     将aaa.gz文件进行解压
[root@localhost test]# gzip -d aaa.gz    作用同上
  
tar
tar类型的的压缩文件应该是大家最常见的吧,在网上下的好多软件也是这种格式的。
参数:
-x 解包.tar文件
-v 显示详细信息
-f 指定解压文件
-z 解压缩
[root@localhost test]# tar -zcvf  tatga.tar.gz  tatgz    压缩tatgz文件夹为tatga.tar.gz压缩文件
注意:
在linux下扩展名不是标识文件的属性
[root@localhost test]# file [文件名]                       查看任何一个文件的类型
[root@localhost test]# tar -cf tatga.tar  tatgz       对tatgz文件打包
[root@localhost test]# gzip tatga.tar                    对tatga.tar包文件压缩
[root@localhost test]# tar -zxvf tatga.tar.gz        对压缩文件进行解压
 
 
zip 
功能:可以压缩文件和目录,是windows 和linux 通用的压缩格式
 
[root@localhost test]# zip a.zip  a                     把a文件压缩成a.zip
[root@localhost test]# zip -r tatgz.zip tatgz      压缩tatgz目录为tatgz.zip
[root@localhost test]# unzip  tatgz.zip              解压文件
 
 
bzip2 
gzip功能基本相同
只能压缩文件
用 -k 命令可以保留原文件 
[root@localhost bzip2]# bzip2 -k fnngj  对fnngj文件进行压缩 
[root@localhost bzip2]# bunzip2  fnngj.bz2   对压缩文件fnngj.bz2进行解压
原文地址:https://www.cnblogs.com/Ellen-study/p/8889242.html