Linux下rar使用简述

出于如下原因,压缩及解压推荐使用zip格式(WINRAR为收费软件)

“RAR是一种专利文件格式,用于数据压缩与归档打包,开发者尤金·罗谢尔(Eugene Roshal),所以RAR的全名是:Roshal ARchive(即”罗谢尔的归档”之意)。首个公开版本RAR 1.3发布于1993年。

尤金·罗谢尔,1972年3月10日生于俄罗斯。毕业于俄罗斯车里雅宾斯克工业大学(Chelyabinsk Technical University),也是FAR文件管理器的作者。他开发程序压缩/解压RAR文件,最初用于DOS,后来移植到其它平台。主要的Windows版本编码器,称为WinRAR,以共享软件的形式发行。不过Roshal公开了解码器源码,UnRAR解码器许可证允许有条件自由发布与修改(条件:不许发布编译RAR兼容编码器)。而RAR编码器一直是有专利的。”

某些情况下,要求在linux上解压rar文件,需要下载rarlinux-3.8.0文件,网上地址一大把,不冗述。简述下在linux下如何解压rar文件:

先解压rarlinux-3.8.0包,并将其中rar及unrar拷贝至/usr/bin中,以后每次可直接调用命令。

查看unrar命令的option:

[[email protected] ~]# unrar --help

UNRAR 3.80 freeware Copyright (c) 1993-2008 Alexander Roshal

Usage: unrar <command> -<switch 1> -<switch N> <archive> <files...>
<@listfiles...> <path_to_extract\>

<Commands>
e Extract files to current directory
l[t,b] List archive [technical, bare]
p Print file to stdout
t Test archive files
v[t,b] Verbosely list archive [technical,bare]
x Extract files with full path

<Switches>
- Stop switches scanning
ad Append archive name to destination path
ap<path> Set path inside archive
av- Disable authenticity verification check
c- Disable comments show
cfg- Disable read configuration
cl Convert names to lower case
cu Convert names to upper case
dh Open shared files
ep Exclude paths from names
ep3 Expand paths to full including the drive letter
f Freshen files
id

以test.rar压缩包为例:

显示压缩包内文件信息,可看到压缩包内文件名,原文件大小,压缩后文件大小,压缩率:

[[email protected] ~]$ unrar l test.rar

UNRAR 3.80 freeware Copyright (c) 1993-2008 Alexander Roshal

Archive test.rar

Name Size Packed Ratio Date Time Attr CRC Meth Ver
-------------------------------------------------------------------------------
zhx_backup_strategy.txt 3127 946 30% 29-04-11 16:46 .....A. B0D97023 m3b 2.9
DG.txt 5266 1954 37% 29-04-11 16:46 .....A. BA9968FF m3b 2.9
INSTALL Oracle 11gR2 on RHEL5 64bit.txt 3926 1675 42% 29-04-11 10:38 .....A. B292F82C m3b 2.9
-------------------------------------------------------------------------------
3 12319 4575 37%

测试压缩文件是否正常:

[or[email protected] ~]$ unrar t test.rar

UNRAR 3.80 freeware Copyright (c) 1993-2008 Alexander Roshal

Testing archive test.rar

Testing zhx_backup_strategy.txt OK
Testing DG.txt OK
Testing INSTALL Oracle 11gR2 on RHEL5 64bit.txt OK
All OK

解压到当前目录:

[[email protected] ~]$ unrar e test.rar

UNRAR 3.80 freeware Copyright (c) 1993-2008 Alexander Roshal

Extracting from test.rar

Extracting zhx_backup_strategy.txt OK
Extracting DG.txt OK
Extracting INSTALL Oracle 11gR2 on RHEL5 64bit.txt OK
All OK

解压到指定目录下:

[[email protected] ~]$ unrar x test.rar ./rar/

UNRAR 3.80 freeware Copyright (c) 1993-2008 Alexander Roshal

Extracting from test.rar

Extracting ./rar/zhx_backup_strategy.txt OK
Extracting ./rar/DG.txt OK
Extracting ./rar/INSTALL Oracle 11gR2 on RHEL5 64bit.txt OK
All OK

option:p可以直接显示压缩包内文件信息,看在压缩包内文件较多的份上,就不做演示。

普人特福的博客cnzz&51la for wordpress,cnzz for wordpress,51la for wordpress