Linux 下压缩与解压.zip和.rar及.7z文件

对于Window下的常见压缩文件.zip和.rar,Linux也有相应的方法来解压它们:

1)对于.zip

linux下提供了zip和unzip程序,zip是压缩程序,unzip是解压程序。它们的参数选项很多,可用命令zip-help和unzip-help查看,这里只做简单介绍,举例说明一下其用法:

#zipyajiu.zipyajiu.jpgyajiu.png

这条命令是将yajiu.jpg和yajiu.png压缩成一个zip包

#zipyajiu.zip*.jpg

这条命令是将所有.jpg的文件压缩成一个zip包

#zip-ryajiu.zipyajiu

这条命令是将文件夹yajiu压缩成一个zip包

#unzipyajiu.zip

这条命令是将yajiu.zip中的所有文件解压出来

yajiu@yajiu-desktop:~$cd图片

yajiu@yajiu-desktop:~/图片zipyajiu.zipyajiu.jpgyajiu.png

updating:yajiu.jpg(deflated34%)

updating:yajiu.png(deflated0%)

yajiu@yajiu-desktop:~/图片$zipyajiu.zip*.jpg

adding:1.jpg(deflated34%)

adding:2.jpg(deflated0%)

yajiu@yajiu-desktop:~/图片$zip-ryajiu.zipyajiu

adding:yajiu/(stored0%)

adding:yajiu/yajiu.zip(stored0%)

adding:yajiu/yajiu.jpg(deflated34%)

adding:yajiu/yajiu.rar(deflated0%)

adding:yajiu/yajiu.7z(deflated0%)

adding:yajiu/yajiu.png(deflated0%)

yajiu@yajiu-desktop:~/图片$unzipyajiu.zip

Archive:yajiu.zip

replace1.jpg?[y]es,[n]o,[A]ll,[N]one,[r]ename:y

inflating:1.jpg

replace2.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

安装:sudoapt-getinstallrarunrar

或者可从http://www.rarsoft.com/download.htm下载RARforLinux编译安装

#tar-xzpvfrarlinux-3.8.0.tar.gz

#cdrar

#make

这样就安装好了,安装之后就有了rar和unrar这两个程序,rar是压缩程序,unrar是解压程序。它们的参数选项很多,可用命令rar-help和unrar-help查看,这里亦简单举例说明一下其用法:

#rarayajiu.raryajiu.jpgyajiu.png

这条命令是将yajiu.jpg和yajiu.png压缩成一个rar包

#rarayajiu.rar*.jpg

这条命令是将所有.jpg的文件压缩成一个rar包

#rarayajiu.raryajiu

这条命令是将文件夹yajiu压缩成一个rar包

#unrareyajiu.rar

这条命令是将yajiu.rar中的所有文件解压出来

yajiu@yajiu-desktop:~$cd图片

yajiu@yajiu-desktop:~/图片$rarayajiu.raryajiu.jpgyajiu.png

RAR3.80beta2Copyright(c)1993-2008AlexanderRoshal16Jun2008

SharewareversionTypeRAR-?forhelp

Evaluationcopy.Pleaseregister.

Creatingarchiveyajiu.rar

Addingyajiu.jpgOK

Addingyajiu.pngOK

Done

yajiu@yajiu-desktop:~/图片$rarayajiu.rar*.jpg

RAR3.80beta2Copyright(c)1993-2008AlexanderRoshal16Jun2008

SharewareversionTypeRAR-?forhelp

Evaluationcopy.Pleaseregister.

Creatingarchiveyajiu.rar

Adding1.jpgOK

Adding2.jpgOK

Done

yajiu@yajiu-desktop:~/图片$rarayajiu.raryajiu

RAR3.80beta2Copyright(c)1993-2008AlexanderRoshal16Jun2008

SharewareversionTypeRAR-?forhelp

Evaluationcopy.Pleaseregister.

Creatingarchiveyajiu.rar

Addingyajiu/yajiu.zipOK

Addingyajiu/yajiu.jpgOK

Addingyajiu/yajiu.rarOK

Addingyajiu/yajiu.7zOK

Addingyajiu/yajiu.pngOK

AddingyajiuOK

Done

yajiu@yajiu-desktop:~/图片$unrareyajiu.rar

UNRAR3.80beta2freewareCopyright(c)1993-2008AlexanderRoshal

Extractingfromyajiu.rar

1.jpgalreadyexists.Overwriteit?

[Y]es,[N]o,[A]ll,n[E]ver,[R]ename,[Q]uitY

Extracting1.jpgOK

7a008fc287fe680c0ff477e9.jpgalreadyexists.Overwriteit?

[Y]es,[N]o,[A]ll,n[E]ver,[R]ename,[Q]uitY

Extracting2.jpgOK

AllOK

yajiu@yajiu-desktop:~/图片$

原文链接:http://hi.baidu.com/zgyz/blog/item/f7ef29085c90d4d663d98665.html

2)对于.7z

支持7Z,ZIP,Zip64,CAB,RAR,ARJ,GZIP,BZIP2,TAR,CPIO,RPM,ISO,DEB压缩文件格式

安装:sudoapt-getinstallp7zipp7zip-fullp7zip-rar

#7zayajiu.7zyajiu.jpgyajiu.png

这条命令是将yajiu.jpg和yajiu.png压缩成一个7z包

#7zayajiu.7z*.jpg

这条命令是将所有.jpg的文件压缩成一个7z包

#7zayajiu.7zyajiu

这条命令是将文件夹yajiu压缩成一个7z包

#7zeyajiu.7z

这条命令是将yajiu.7z中的所有文件解压出来,e是解压到当前路径

#7zxyajiu.7z

这条命令是将yajiu.7z中的所有文件解压出来,x是解压到压缩包命名的目录下

yajiu@yajiu-desktop:~$cd图片

yajiu@yajiu-desktop:~/图片$7zayajiu.7zyajiu.jpgyajiu.png

7-Zip(A)4.58betaCopyright(c)1999-2008IgorPavlov2008-05-05

p7zipVersion4.58(locale=zh_CN.UTF-8,Utf16=on,HugeFiles=on,2CPUs)

Scanning

Creatingarchiveyajiu.7z

Compressingyajiu.jpg

Compressingyajiu.png

EverythingisOk

yajiu@yajiu-desktop:~/图片$7zayajiu.7z*.jpg

7-Zip(A)4.58betaCopyright(c)1999-2008IgorPavlov2008-05-05

p7zipVersion4.58(locale=zh_CN.UTF-8,Utf16=on,HugeFiles=on,2CPUs)

Scanning

Creatingarchiveyajiu.7z

Compressing1.jpg

Compressing2.jpg

EverythingisOk

yajiu@yajiu-desktop:~/图片$7zayajiu.7zyajiu

7-Zip(A)4.58betaCopyright(c)1999-2008IgorPavlov2008-05-05

p7zipVersion4.58(locale=zh_CN.UTF-8,Utf16=on,HugeFiles=on,2CPUs)

Scanning

Creatingarchiveyajiu.7z

Compressingyajiu/yajiu.7z

Compressingyajiu/yajiu.rar

Compressingyajiu/yajiu.zip

Compressingyajiu/yajiu.jpg

Compressingyajiu/yajiu.png

EverythingisOk

yajiu@yajiu-desktop:~/图片$7zxyajiu.7z

7-Zip4.58betaCopyright(c)1999-2008IgorPavlov2008-05-05

p7zipVersion4.58(locale=zh_CN.UTF-8,Utf16=on,HugeFiles=on,2CPUs)

Processingarchive:yajiu.7z

file1.jpg

alreadyexists.Overwritewith

1.jpg?

(Y)es/(N)o/(A)lways/(S)kipall/A(u)torename/(Q)uit?Y

Extracting1.jpg

file2.jpg

alreadyexists.Overwritewith

2.jpg?

(Y)es/(N)o/(A)lways/(S)kipall/A(u)torename/(Q)uit?Y

Extracting2.jpg

EverythingisOk

Files:2

Size:112564

Compressed:96228

yajiu@yajiu-desktop:~/图片$

原文链接:http://hi.baidu.com/zgyz/blog/item/f7ef29085c90d4d663d98665.html

相关推荐