如何在linux下解压缩rar格式的文件压缩包

来源:互联网 发布:网络不稳定怎么回事 编辑:程序博客网 时间:2024/05/16 07:59
如何在linux下解压缩rar格式的文件压缩包
下载rarlinux-5.1.1.tar.gz
http://linux.softpedia.com/get/System/Archiving/RAR-2380.shtml
安装
tar xvf rarlinux-5.1.1.tar.gz -C /usr/local
cd /usr/local/rar/
make

具体例子

实例:

[root@bogon Downloads]# unrar e The\ C\ programming\ Language\[C程序设计语言\]PDF.rar

UNRAR 5.11 freeware      Copyright (c) 1993-2014 Alexander Roshal


Extracting from The C programming Language[C程序设计语言]PDF.rar

Extracting  The C Programming Language 中文版.pdf                        OK
Extracting  The C Programming Language.pdf                            OK
All OK

[root@bogon Downloads]# rar x The\ C\ programming\ Language\[C程序设计语言\]PDF.rar

RAR 5.11   Copyright (c) 1993-2014 Alexander Roshal   27 Aug 2014
Trial version             Type RAR -? for help


Extracting from The C programming Language[C程序设计语言]PDF.rar

Extracting  The C Programming Language 中文版.pdf                        OK
Extracting  The C Programming Language.pdf                            OK
All OK

更多命令 查看帮助

[root@bogon Downloads]# rar

RAR 5.11   Copyright (c) 1993-2014 Alexander Roshal   27 Aug 2014
Trial version             Type RAR -? for help

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

<Commands>
a             Add files to archive
c             Add archive comment
ch            Change archive parameters
cw            Write archive comment to file
d             Delete files from archive
e             Extract files without archived paths
f             Freshen files in archive
i[par]=<str>  Find string in archives
k             Lock archive
l[t[a],b]     List archive contents [technical[all], bare]
m[f]          Move to archive [files only]
p             Print file to stdout
r             Repair archive
rc            Reconstruct missing volumes
rn            Rename archived files
rr[N]         Add data recovery record
rv[N]         Create recovery volumes
s[name|-]     Convert archive to or from SFX
t             Test archive files
u             Update files in archive
v[t[a],b]     Verbosely list archive contents [technical[all],bare]
x             Extract files with full path

<Switches>
-             Stop switches scanning
@[+]          Disable [enable] file lists
ad            Append archive name to destination path
ag[format]    Generate archive name using the current date
ai            Ignore file attributes
ap<path>      Set path inside archive
as            Synchronize archive contents
c-            Disable comments show
cfg-          Disable read configuration
cl            Convert names to lower case
cu            Convert names to upper case
df            Delete files after archiving
dh            Open shared files
ds            Disable name sort for solid archive
dw            Wipe files after archiving
e[+]<attr>    Set file exclude and include attributes
ed            Do not add empty directories
en            Do not put 'end of archive' block
ep            Exclude paths from names
ep1           Exclude base directory from names
ep3           Expand paths to full including the drive letter
f             Freshen files
hp[password]  Encrypt both file data and headers
ht[b|c]       Select hash type [BLAKE2,CRC32] for file checksum
id[c,d,p,q]   Disable messages
    ierr          Send all messages to stderr
ilog[name]    Log errors to file (registered versions only)
    inul          Disable all messages
    isnd          Enable sound
    k             Lock archive
    kb            Keep broken extracted files
    log[f][=name] Write names to log file
m<0..5>       Set compression level (0-store...3-default...5-maximal)
    ma[4|5]       Specify a version of archiving format
    mc<par>       Set advanced compression parameters
    md<n>[k,m,g]  Dictionary size in KB, MB or GB
    ms[ext;ext]   Specify file types to store
    mt<threads>   Set the number of threads
    n<file>       Additionally filter included files
    n@            Read additional filter masks from stdin
    n@<list>      Read additional filter masks from list file
    o[+|-]        Set the overwrite mode
    oh            Save hard links as the link instead of the file
    oi[0-4][:min] Save identical files as references
    ol            Save symbolic links as the link instead of the file
    or            Rename files automatically
    ow            Save or restore file owner and group
    p[password]   Set password
    p-            Do not query password
    qo[-|+]       Add quick open information [none|force]
    r             Recurse subdirectories
    r-            Disable recursion
    r0            Recurse subdirectories for wildcard names only
    rr[N]         Add data recovery record
    rv[N]         Create recovery volumes
    s[<N>,v[-],e] Create solid archive
    s-            Disable solid archiving
    sc<chr>[obj]  Specify the character set
    sfx[name]     Create SFX archive
si[name]      Read data from standard input (stdin)
    sl<size>      Process files with size less than specified
    sm<size>      Process files with size more than specified
    t             Test files after archiving
    ta<date>      Process files modified after <date> in YYYYMMDDHHMMSS format
    tb<date>      Process files modified before <date> in YYYYMMDDHHMMSS format
    tk            Keep original archive time
    tl            Set archive time to latest file
    tn<time>      Process files newer than <time>
    to<time>      Process files older than <time>
ts<m,c,a>[N]  Save or restore file time (modification, creation, access)
    u             Update files
    v<size>[k,b]  Create volumes with size=<size>*1000 [*1024, *1]
    ver[n]        File version control
    vn            Use the old style volume naming scheme
    vp            Pause before each volume
    w<path>       Assign work directory
    x<file>       Exclude specified file
    x@            Read file names to exclude from stdin
    x@<list>      Exclude files listed in specified list file
    y             Assume Yes on all queries
    z[file]       Read archive comment from file

***************************************************************************************************************

  a 添加文件到操作文档
  例:rar a test.rar file1.txt
若test.rar文件不存在,则打包file1.txt文件成test.rar
  例:rar a test.rar file2.txt
若test.rar文件已经存在,则添加file2.txt文件到test.rar中
  (这样test.rar中就有两个文件了)
  注,如果操作文档中已有某文件的一份拷贝,则a命令更新该文件,对目录也可以进行操作
  例:rar a test.rar dir1
  c 对操作文档添加说明注释
  rar c test.rar
  (会出现Reading comment from
stdin字样,然后输入一行或多行注释,以ctrl+d结束)
  cf 添加文件注释,类似上面的c,不过这个是对压缩文档中每个文件进行注释
  cw 将文档注释写入文件
  例:rar cw test.rar comment.txt
  d 从文档中删除文件
  例:rar d test.rar file1.txt
  e 将文件解压到当前目录
  例:rar e test.rar
  注:用e解压的话,不仅原来的file1.txt和file2.txt被解压到当前目录,就连dir1里面的所有文件
  也被解压到当前目录下,不能保持压缩前的目录结构,如果想保持压缩前的目录结构,用x解压
  k 锁定文档
  例:rar k test.rar 锁定文档后,该文档就无法进行任何更新操作了
  r 修复文档
  例:rar r test.rar
  当rar文件有问题时,可以尝试用该命令进行修复(鬼知道有多少用)
  s 转换文档成自解压文档
  例:rar s test.rar
  会生成一个test.sfx的可执行文档,运行它的效果就相当于rar x test.rar,
  适合于向没有rar的用户传输文件
  t 检测文档
  例:rar t test.rar
  检测test.rar的完整性,一般压缩完大型文件准备传输前最好用这个命令来确保文件的正确性
  x 带路径解压文档中内容到当前目录
  例:rar x test.rar
  这样解压的话,dir1就会保持原来的目录结构
  以上就是rar的常用命令,一个rar操作只能有一个命令,而选项却可以有多个。
  ------------------------------------------------------------------------
  rar选项有很多,在此无法一一说明,只示范经常使用的几个
  cl 将文件名转换为小写
  cu 将文件名转换为大写
  例:rar a -cl test.rar FILe.txt
  FILe.txt在添加进test.rar之后,变为file.txt
  df 文档操作后删除源文件
  例:rar a -df test.rar file1.txt file2.txt dir1
  将file1.txt,file2.txt,dir1压缩到test.rar中之后,删除源文件
  ed 不添加空目录
  例:rar a -ed test.rar dir1
  添加dir1到test.rar中时,不对空目录进行操作
  rar e -ed test.rar
  解压test.rar时,不生成空目录
  k 锁定文件
  例:rar a -k test.rar file1.txt
  等价于rar a test.rar file1.txt
  rar k test.rar
  m<0..5> 设定压缩比等级(0-存储,3-默认,5-最大)
  例:rar a -m0 test.rar dir1 dir2
  将dir1,dir2打包存储到test.rar,不进行实质上的压缩(速度奇快,适合于对无甚可压的文件进行操作
  比如avi,jpg等)
  rar a -m5 test.rar *.txt *.bmp
  将当前目录下的txt文件和bmp文件打包压缩到test.rar中,使用最大压缩比(最慢)
  ms[ext;ext] 特定文件采用非压缩方式
  例:rar a -m5 -ms avi;jpg;jpeg test.rar /home
  将home目录下所有目录和文件归档到test.rar,采用最大压缩,但avi,jpg,jpeg文件不进行压缩
  (只是打包进test.rar,因为这些文件即使用最大压缩也压不了多少,不如直接打包节省时间)
  o+ 覆盖已有文件
  o- 不覆盖已有文件
  例:rar x -o- test.rar
  解压test.rar文件,但是如果碰到以存在的文件则不覆盖
  ol 将符号链接以链接文件保存,而不是普通文件
  ow 保存或者恢复文件所有者的信息(username,group)
  这两个是*nix系统特有的命令,很容易理解吧
  ------------------------------------------------------------------------
  p[password] 设定密码
  例:rar a test.rar *.txt -p prettygirl
  压缩文件设定密码为prettygirl,解压时无密码无法进行操作
  如果觉得明码密码太过暴露,可以使用
  rar a test.rar *.txt -p
  则rar程序会询问你要使用什么密码,不回显
  s- 不使用固实压缩
  注,固实压缩就是压缩后文档内容不可变更的压缩方式,这和lock不一样。因为使用普通压缩
  要照顾以后的插入删除个别文件的需要,就要留下很多操作余地。而固实压缩则不可以对
  其内容进行任何更新,所以压缩比是最大的。
  sfx[name] 创建自解压文件,这和先用a进行压缩,再用s转换效果是一样的。
  t 压缩完毕后进行完整性检验
  例:rar a test.rar /home -t
  压缩完毕后进行检验,如果有问题则报错。
  ta 仅对data日期后文件进行操作
  tb 仅对data日期前文件进行操作
  注,date的格式为 YYYYMMDDHHMMSS 这样。
  v[k,b] 分卷压缩,每卷大小由后面的size指定
  例:rar a -v15000k -m0 test xvid-fn.avi
  对xvid-fn.avi进行打包存储,每卷大小15000k(这种格式在网上发布dvdrip时很流行)
  生成的文件名为test.part1.rar,test.part2.rar….(rar 3.20版)
  x 排除特定的文件
  例:rar x test.rar -x *.txt
  解压test.rar中除*.txt以外的文档
  x@ 同上,不过这次所有排除的文件放在list文件列表中
  y 所有操作均回答yes
  例如有时解压时每碰到相同文件就问是否覆盖(Y/N),加上-y就可以默认选择Yes,不再询问
0 0
原创粉丝点击