Linux學習之文件的壓縮與解壓
阿新 • • 發佈:2018-04-20
zip2 壓縮命令 unzip 文件夾 擴展 格式 應該 host bz2 下面來學習四個常用的壓縮命令。
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進行解壓
Linux學習之文件的壓縮與解壓