Linux 下壓縮與解壓.zip和.rar及.7z檔案
Linux 下壓縮與解壓.zip和.rar及.7z檔案
對于Window下的常見壓縮檔案.zip和.rar,Linux也有相應的方法來解壓它們:
1)對于.zip
linux下提供了zip和unzip程式,zip是壓縮程式,unzip是解壓程式。它們的參數選項很多,可用指令zip -help和unzip -help檢視,這裡隻做簡單介紹,舉例說明一下其用法:
# zip yajiu.zip yajiu.jpg yajiu.png
這條指令是将yajiu.jpg和yajiu.png壓縮成一個zip包
# zip yajiu.zip *.jpg
這條指令是将所有.jpg的檔案壓縮成一個zip包
# zip -r yajiu.zip yajiu
這條指令是将檔案夾yajiu壓縮成一個zip包
# unzip yajiu.zip
這條指令是将yajiu.zip中的所有檔案解壓出來
[email protected]:~$ cd 圖檔
[email protected]:~/圖檔zip yajiu.zip yajiu.jpg yajiu.png
updating: yajiu.jpg (deflated 34%)
updating: yajiu.png (deflated 0%)
[email protected]:~/圖檔$ zip yajiu.zip *.jpg
adding: 1.jpg (deflated 34%)
adding: 2.jpg (deflated 0%)
[email protected]:~/圖檔$ zip -r yajiu.zip yajiu
adding: yajiu/ (stored 0%)
adding: yajiu/yajiu.zip (stored 0%)
adding: yajiu/yajiu.jpg (deflated 34%)
adding: yajiu/yajiu.rar (deflated 0%)
adding: yajiu/yajiu.7z (deflated 0%)
adding: yajiu/yajiu.png (deflated 0%)
[email protected]:~/圖檔$ unzip yajiu.zip
Archive: yajiu.zip
replace 1.jpg? [y]es, [n]o, [A]ll, [N]one, [r]ename: y
inflating: 1.jpg
replace 2.jpg? [y]es, [n]o, [A]ll, [N]one, [r]ename: y
inflating: 2.jpg
[email protected]:~/圖檔$
原文連結:
http://hi.baidu.com/zgyz/blog/item/f7ef29085c90d4d663d98665.html
2)對于.rar
安裝: sudo apt-get install rar unrar
或者可從http://www.rarsoft.com/download.htm下載下傳 RAR for Linux 編譯安裝
# tar -xzpvf rarlinux-3.8.0.tar.gz
# cd rar
# make
這樣就安裝好了,安裝之後就有了rar和unrar這兩個程式,rar是壓縮程式,unrar是解壓程式。它們的參數選項很多,可用指令rar -help和unrar -help檢視,這裡亦簡單舉例說明一下其用法:
# rar a yajiu.rar yajiu.jpg yajiu.png
這條指令是将yajiu.jpg和yajiu.png壓縮成一個rar包
# rar a yajiu.rar *.jpg
這條指令是将所有.jpg的檔案壓縮成一個rar包
# rar a yajiu.rar yajiu
這條指令是将檔案夾yajiu壓縮成一個rar包
# unrar e yajiu.rar
這條指令是将yajiu.rar中的所有檔案解壓出來
按目錄路徑解壓出來 unrar x test.rar /test/
2)對于.7z
支援 7Z,ZIP,Zip64,CAB,RAR,ARJ,GZIP,BZIP2,TAR,CPIO,RPM,ISO,DEB 壓縮檔案格式
安裝: sudo apt-get install p7zip p7zip-full p7zip-rar
# 7z a yajiu.7z yajiu.jpg yajiu.png
這條指令是将yajiu.jpg和yajiu.png壓縮成一個7z包
# 7z a yajiu.7z *.jpg
這條指令是将所有.jpg的檔案壓縮成一個7z包
# 7z a yajiu.7z yajiu
這條指令是将檔案夾yajiu壓縮成一個7z包
# 7z e yajiu.7z
這條指令是将yajiu.7z中的所有檔案解壓出來,e是解壓到目前路徑
# 7z x yajiu.7z
這條指令是将yajiu.7z中的所有檔案解壓出來,x是解壓到壓縮包命名的目錄下
[email protected]:~$ cd 圖檔
[email protected]:~/圖檔$ 7z a yajiu.7z yajiu.jpg yajiu.png
7-Zip (A) 4.58 beta Copyright (c) 1999-2008 Igor Pavlov 2008-05-05
p7zip Version 4.58 (locale=zh_CN.UTF-8,Utf16=on,HugeFiles=on,2 CPUs)
Scanning
Creating archive yajiu.7z
Compressing yajiu.jpg
Compressing yajiu.png
Everything is Ok
[email protected]:~/圖檔$ 7z a yajiu.7z *.jpg
7-Zip (A) 4.58 beta Copyright (c) 1999-2008 Igor Pavlov 2008-05-05
p7zip Version 4.58 (locale=zh_CN.UTF-8,Utf16=on,HugeFiles=on,2 CPUs)
Scanning
Creating archive yajiu.7z
Compressing 1.jpg
Compressing 2.jpg
Everything is Ok
[email protected]:~/圖檔$ 7z a yajiu.7z yajiu
7-Zip (A) 4.58 beta Copyright (c) 1999-2008 Igor Pavlov 2008-05-05
p7zip Version 4.58 (locale=zh_CN.UTF-8,Utf16=on,HugeFiles=on,2 CPUs)
Scanning
Creating archive yajiu.7z
Compressing yajiu/yajiu.7z
Compressing yajiu/yajiu.rar
Compressing yajiu/yajiu.zip
Compressing yajiu/yajiu.jpg
Compressing yajiu/yajiu.png
Everything is Ok
[email protected]:~/圖檔$ 7z x yajiu.7z
7-Zip 4.58 beta Copyright (c) 1999-2008 Igor Pavlov 2008-05-05
p7zip Version 4.58 (locale=zh_CN.UTF-8,Utf16=on,HugeFiles=on,2 CPUs)
Processing archive: yajiu.7z
file 1.jpg
already exists. Overwrite with
1.jpg?
(Y)es / (N)o / (A)lways / (S)kip all / A(u)to rename / (Q)uit? Y
Extracting 1.jpg
file 2.jpg
already exists. Overwrite with
2.jpg?
(Y)es / (N)o / (A)lways / (S)kip all / A(u)to rename / (Q)uit? Y
Extracting 2.jpg
Everything is Ok
Files: 2
Size: 112564
Compressed: 96228
[email protected]:~/圖檔$