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中的所有文件解压出来
yajiu@yajiu-desktop:~$ cd 图片
yajiu@yajiu-desktop:~/图片zip yajiu.zip yajiu.jpg yajiu.png
updating: yajiu.jpg (deflated 34%)
updating: yajiu.png (deflated 0%)
yajiu@yajiu-desktop:~/图片$ zip yajiu.zip *.jpg
adding: 1.jpg (deflated 34%)
adding: 2.jpg (deflated 0%)
yajiu@yajiu-desktop:~/图片$ 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%)
yajiu@yajiu-desktop:~/图片$ 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
yajiu@yajiu-desktop:~/图片$
原文链接: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中的所有文件解压出来
yajiu@yajiu-desktop:~$ cd 图片
yajiu@yajiu-desktop:~/图片$ rar a yajiu.rar yajiu.jpg yajiu.png
RAR 3.80 beta 2 Copyright (c) 1993-2008 Alexander Roshal 16 Jun 2008
Shareware version Type RAR -? for help
Evaluation copy. Please register.
Creating archive yajiu.rar
Adding yajiu.jpg OK
Adding yajiu.png OK
Done
yajiu@yajiu-desktop:~/图片$ rar a yajiu.rar *.jpg
RAR 3.80 beta 2 Copyright (c) 1993-2008 Alexander Roshal 16 Jun 2008
Shareware version Type RAR -? for help
Evaluation copy. Please register.
Creating archive yajiu.rar
Adding 1.jpg OK
Adding&nbs