RAR 是用于创建和提取压缩存档 (.rar)
文件的最流行的工具。当我们从网上下载存档文件时,我们需要一个 rar 工具来提取它们。
RAR 在 Windows 操作系统下可以免费使用来处理压缩文件,但遗憾的是,rar 工具没有在 Linux 系统下预装。
本文介绍如何在 Linux 系统下使用官方二进制 tar 文件安装 unrar 和 rar 命令行工具, 用于打开、提取、解压缩或unrar 存档文件。
第一步: 安装 rar
去 RARLAB 下载最新的 unrar/rar 文件 使用以下命令安装.
# root 用户安装
# wget https://www.rarlab.com/rar/rarlinux-x64-610.tar.gz
# tar -xf rarlinux-x64-610.tar.gz
# cd rar
# cp -v rar unrar /usr/local/bin/
# 普通用户安装
$ mkdir -p $HOME/.local/bin
$ export PATH="$HOME/.local/bin:$PATH"
$ ln -s $HOME/rar/rar $HOME/.local/bin/rar
$ ln -s $HOME/rar/unrar $HOME/.local/bin/unrar
注册 RAR
将 rarreg.key
拷贝到用户目录 /home/user
或者拷贝到以下任意文件夹
/etc
/usr/lib
/usr/local/lib
/usr/local/etc
如果你愿意也可以重命名为 .rarreg.key
或者 .rarregkey
, rarreg.key
也是有效的.
网上搜集到的可用注册码
RAR 6.10 Copyright (c) 1993-2022 Alexander Roshal 24 Jan 2022
Registered to Federal Agency for Education
RAR registration data
Federal Agency for Education
1000000 PC usage license
UID=b621cca9a84bc5deffbf
6412612250ffbf533df6db2dfe8ccc3aae5362c06d54762105357d
5e3b1489e751c76bf6e0640001014be50a52303fed29664b074145
7e567d04159ad8defc3fb6edf32831fd1966f72c21c0c53c02fbbb
2f91cfca671d9c482b11b8ac3281cb21378e85606494da349941fa
e9ee328f12dc73e90b6356b921fbfb8522d6562a6a4b97e8ef6c9f
fb866be1e3826b5aa126a4d2bfe9336ad63003fc0e71c307fc2c60
64416495d4c55a0cc82d402110498da970812063934815d81470829275
RAR 6.10 Copyright (c) 1993-2022 Alexander Roshal 24 Jan 2022
Registered to WinRAR
RAR registration data
WinRAR
Unlimited Company License
UID=4b914fb772c8376bf571
6412212250f5711ad072cf351cfa39e2851192daf8a362681bbb1d
cd48da1d14d995f0bbf960fce6cb5ffde62890079861be57638717
7131ced835ed65cc743d9777f2ea71a8e32c7e593cf66794343565
b41bcf56929486b8bcdac33d50ecf773996052598f1f556defffbd
982fbe71e93df6b6346c37a3890f3c7edc65d7f5455470d13d1190
6e6fb824bcf25f155547b5fc41901ad58c0992f570be1cf5608ba9
aef69d48c864bcd72d15163897773d314187f6a9af350808719796
RAR 6.10 Copyright (c) 1993-2022 Alexander Roshal 24 Jan 2022
Registered to State Grid Corporation Of China
RAR registration data
State Grid Corporation Of China
50000 PC usage license
UID=5827a0bd1c43525d0a5d
64122122500a5d3d56f784f3a440ac3fb632d34e08bbaa37fc7712
6acaeb8eb044810272e86042cb7c79b1da0eaf88c79f8a7c6dd77b
dba335e27a109997ac90fb0e10e4129e79f46c42b4ee1832fa5113
7443fcc1124840d4dd36f3af84a5c915a760b18c6394f938168227
fbf29edbc4b34ef85ee53fbfca71814a82afadf073876b4b033451
b6292a7cc7975b3ff3cc73404abbf7c126787344169eeae4609f62
c9ffbc159bf2640ad5d9b88f8fa9d9cbf2b7e5b022a21938465244
How to transfer WinRAR key to Linux
第二步: 提取 RAR 文件
文件夹原始结构
$ tree
├── acesheep
| ├── abc.txt
| ├── index.html
| ├── index.php
| └── xyz.txt
├── default
| ├── index.html
| └── index.php
├── include
| └── abc.txt
└── php
└── xyz.txt
4 directories, 8 files
要在当前工作目录中提取 RAR 文件, 使用 unrar e
e 解压选项
会忽略压缩包的路径, 将所有内容解压到当前文件夹. 如果压缩包存在同名文件他会询问是否覆盖
$ unrar e acesheep.rar
UNRAR 6.10 freeware Copyright (c) 1993-2022 Alexander Roshal
Extracting from acesheep.rar
Extracting xyz.txt OK
Extracting index.html OK
Extracting index.php OK
Extracting abc.txt OK
Would you like to replace the existing file index.html
0 bytes, modified on 2022-02-25 10:33
with a new one
0 bytes, modified on 2022-02-25 10:34
[Y]es, [N]o, [A]ll, n[E]ver, [R]ename, [Q]uit a
Extracting index.html OK
Extracting index.php OK
Extracting abc.txt OK
Extracting xyz.txt OK
All OK
提取 RAR 文件到指定路径
$ unrar e acesheep.rar ace/
UNRAR 6.10 freeware Copyright (c) 1993-2022 Alexander Roshal
Extracting from acesheep.rar
Extracting ace/xyz.txt OK
Extracting ace/index.html OK
Extracting ace/index.php OK
Extracting ace/abc.txt OK
Would you like to replace the existing file ace/index.html
0 bytes, modified on 2022-02-25 10:33
with a new one
0 bytes, modified on 2022-02-25 10:34
[Y]es, [N]o, [A]ll, n[E]ver, [R]ename, [Q]uit a
Extracting ace/index.html OK
Extracting ace/index.php OK
Extracting ace/abc.txt OK
Extracting ace/xyz.txt OK
All OK
提取 RAR 文件并包含目录结构, 使用 unrar x
一般情况下使用 x
解压
它将根据文件夹结构进行提取,请参见下面的命令输出。
$ unrar x acesheep.rar
UNRAR 6.10 freeware Copyright (c) 1993-2022 Alexander Roshal
Extracting from acesheep.rar
Creating acesheep OK
Extracting acesheep/xyz.txt OK
Extracting acesheep/index.html OK
Extracting acesheep/index.php OK
Extracting acesheep/abc.txt OK
Creating default OK
Extracting default/index.html OK
Extracting default/index.php OK
Creating include OK
Extracting include/abc.txt OK
Creating php OK
Extracting php/xyz.txt OK
All OK
第三步: 查看 RAR 压缩文件列表 | 列出 RAR 压缩包内容
要列出存档文件中的文件,使用 unrar l
。它将显示文件列表及其 大小、日期、时间、权限
$ unrar l acesheep.rar
UNRAR 6.10 freeware Copyright (c) 1993-2022 Alexander Roshal
Archive: acesheep.rar
Details: RAR 5
Attributes Size Date Time Name
----------- --------- ---------- ----- ----
-rw-r--r-- 0 2022-02-25 10:33 acesheep/xyz.txt
-rw-r--r-- 0 2022-02-25 10:33 acesheep/index.html
-rw-r--r-- 0 2022-02-25 10:33 acesheep/index.php
-rw-r--r-- 0 2022-02-25 10:33 acesheep/abc.txt
-rw-r--r-- 0 2022-02-25 10:34 default/index.html
-rw-r--r-- 0 2022-02-25 10:34 default/index.php
-rw-r--r-- 0 2022-02-25 10:37 include/abc.txt
-rw-r--r-- 0 2022-02-25 10:37 php/xyz.txt
----------- --------- ---------- ----- ----
0 8
第四步: 测试 RAR 压缩文件 | 检查压缩包完整性
要测试存档文件的完整性, 使用 unrar t
。下面的命令将对每个文件执行完整的完整性检查并显示文件的状态。
$ unrar t acesheep.rar
UNRAR 6.10 freeware Copyright (c) 1993-2022 Alexander Roshal
Testing archive acesheep.rar
Testing acesheep/xyz.txt OK
Testing acesheep/index.html OK
Testing acesheep/index.php OK
Testing acesheep/abc.txt OK
Testing default/index.html OK
Testing default/index.php OK
Testing include/abc.txt OK
Testing php/xyz.txt OK
All OK
unrar
命令只能用于提取、列出或测试压缩文件。它不能创建RAR压缩文件. 因此, 我们需要使用 rar
命令来创建压缩文件。
第五步: 创建 RAR 压缩文件
创建 RAR 压缩文件, 使用 rar a
它会把 acesheep
文件夹包含到压缩包中
$ rar a acesheep.rar acesheep
RAR 6.10 Copyright (c) 1993-2022 Alexander Roshal 24 Jan 2022
Registered to WinRAR
Updating archive acesheep.rar
Updating acesheep/xyz.txt OK
Updating acesheep/index.html OK
Updating acesheep/index.php OK
Updating acesheep/abc.txt OK
Adding acesheep OK
Done
第六步: 从存档中删除文件 | 从压缩包中删除文件
从压缩包中删除 acesheep/abc.txt
$ rar d acesheep.rar acesheep/abc.txt
第七步: 恢复压缩包 | 修复压缩包
恢复 / 修复 压缩包使用 rar r
, 会在同目录下创建 rebuilt.acesheep.rar
文件
需要压缩时使用 -rr
参数, 留空默认为 3% 等于 -rr3p
, 3 - 10% 的恢复记录是比较合理的选择
$ rar r acesheep.rar
RAR 6.10 Copyright (c) 1993-2022 Alexander Roshal 24 Jan 2022
Registered to WinRAR
Data recovery record not found
Reconstructing acesheep.rar
Building rebuilt.acesheep.rar 8%
Found acesheep/xyz.txt 26%
Found acesheep/index.html 45%
Found acesheep/index.php 64%
Found acesheep/abc.txt 82%
Found acesheep 100%
Done
第八步: 更新压缩包 | 在现有压缩包中添加文件
向现有压缩文件中 更新 或 添加, 使用 rar u
$ rar u acesheep.rar acesheep.sql
RAR 6.10 Copyright (c) 1993-2022 Alexander Roshal 24 Jan 2022
Registered to WinRAR
Updating archive acesheep.rar
Adding acesheep.sql OK
Done
现在, 验证文件 acesheep.sql
是否已添加到压缩文件中。
$ rar l acesheep.rar
RAR 6.10 Copyright (c) 1993-2022 Alexander Roshal 24 Jan 2022
Registered to WinRAR
Archive: acesheep.rar
Details: RAR 5
Attributes Size Date Time Name
----------- --------- ---------- ----- ----
-rw-r--r-- 0 2022-02-25 10:33 acesheep/xyz.txt
-rw-r--r-- 0 2022-02-25 10:33 acesheep/index.html
-rw-r--r-- 0 2022-02-25 10:33 acesheep/index.php
-rw-r--r-- 0 2022-02-25 10:33 acesheep/abc.txt
drwxr-xr-x 0 2022-02-25 12:27 acesheep
-rw-r--r-- 0 2022-02-25 13:36 acesheep.sql
----------- --------- ---------- ----- ----
0 6
第九步: 创建带密码的压缩文件 | 给压缩文件设置密码
要密码保护压缩文件, 使用 rar a -p
或者 rar a -p51522zzwlwlbb
密码为 51522zzwlwlbb
$ rar a -p acesheep.rar acesheep.sql
Enter password (will not be echoed):
Reenter password:
RAR 6.10 Copyright (c) 1993-2022 Alexander Roshal 24 Jan 2022
Registered to WinRAR
Updating archive acesheep.rar
Updating acesheep.sql OK
Done
现在通过提取压缩文件来验证它, 看看它是否会提示我们输入上面设置的密码。
$ rar x acesheep.rar
RAR 6.10 Copyright (c) 1993-2022 Alexander Roshal 24 Jan 2022
Registered to WinRAR
Extracting from acesheep.rar
Creating acesheep OK
Extracting acesheep/xyz.txt OK
Extracting acesheep/index.html OK
Extracting acesheep/index.php OK
Extracting acesheep/abc.txt OK
Enter password (will not be echoed) for acesheep.sql:
Extracting acesheep.sql OK
All OK
第十步: 锁定压缩文件
它提供了一个选项来锁定压缩文件, 防止更新 / 添加 / 修改
WinRAR 无法修改锁定的存档。您可以锁定重要档案以防止其被意外修改。
$ rar k acesheep.rar
RAR 6.10 Copyright (c) 1993-2022 Alexander Roshal 24 Jan 2022
Registered to WinRAR
Processing archive acesheep.rar
Locking archive
Done
分卷压缩参数 单位
-V<n>[k|b|f|m|M|g|G]
- 设置分卷压缩
创建尺寸为 <n>*1000
的分卷
默认情况下, 此选项使用 <n>
乘以 1000 bytes (不是 1024 bytes)
可以在结尾使用不同符号来表示计算单位
符号 | 值 |
---|---|
k | KiB = 1024 bytes |
b | bytes = 1 bytes |
f | 预定义值可以是 360、720、1200、1440 或 2880,或替换为相应的软盘大小。如果省略大小,将使用自动检测。 |
m | MiB = 1024 bytes |
M | MB = 1000 bytes |
g | GiB = 1024 bytes |
G | GB = 1000 bytes |
允许使用点作为小数点输入小数部分。例如,-v1.5g
表示 1.5 GiB
。
您可以指定多个 -v 参数来为不同的卷设置不同的大小。
rar a -v100k -v200k -v300k acesheep.rar
为第一个分卷设置 100 KiB
大小, 为第二个分卷设置 200 KiB
, 为后续所有分卷设置 300 KiB
。
# 使用 -v10G
$ ls -all mysql-5.7.31-winx64.part01.rar
-rw-r--r-- 1 user user 10000000000 Feb 22 01:51 mysql-5.7.31-winx64.part01.rar
# 使用 -v10g
$ ls -all mysql-5.7.31-winx64.part01.rar
-rw-r--r-- 1 user user 10737418240 Feb 22 14:09 mysql-5.7.31-winx64.part01.rar
实际运用
这个命令需要进入到需要压缩文件的上层目录运行
[root@server temp]# tree -L 1
temp
├── mysql-5.7.31-winx64.rar
└── mysql-5.7.31-winx64/
[root@server temp]# rar a -m5 -ma5 -md128MB -mt2 -v10g -r -k mysql-5.7.31-winx64.rar mysql-5.7.31-winx64/
参数 | 作用 |
---|---|
-m5 | 使用最高压缩级别 5 |
-ma5 | RAR 存档格式 RAR5 |
-md128MB | 字典大小 128MB |
-mt2 | 压缩线程数 2 |
-v10g | 分卷压缩每个包10GiB |
-r | 递归子目录 |
-k | 锁定压缩文件禁止修改 |
不在同一层目录时压缩
当我们不在需要压缩的文件上层目录时, 使用绝对路径压缩. 会把整个路径同时存储到压缩包中.
接下来的几个参数可以解决这个问题
目录结构如下, 我们在 WorkFolder
中, 使用绝对路径压缩 FolderToArchive
文件夹.
[root@server ~]# tree temp
temp
├── FolderToArchive
│ ├── File1
│ ├── File2
│ ├── File3
│ ├── FolderA
│ │ ├── FileX
│ │ ├── FileY
│ │ └── FileZ
│ └── FolderB
│ ├── FileA
│ ├── FileB
│ └── FileC
└── WorkFolder
4 directories, 9 files
- 错误示范, 如果此时仍然使用上面命令. 虽然我们没有指定, 但是参数中有
-ep2
默认参数
[root@server WorkFolder]# rar a -m5 -ma5 -md128MB -r -k acesheep.rar /temp/FolderToArchive/
RAR 6.10 Copyright (c) 1993-2022 Alexander Roshal 24 Jan 2022
Registered to WinRAR
Creating archive acesheep.rar
Adding /temp/FolderToArchive/File2 OK
Adding /temp/FolderToArchive/File1 OK
Adding /temp/FolderToArchive/FolderA/FileX OK
Adding /temp/FolderToArchive/FolderA/FileY OK
Adding /temp/FolderToArchive/FolderA/FileZ OK
Adding /temp/FolderToArchive/File3 OK
Adding /temp/FolderToArchive/FolderB/FileB OK
Adding /temp/FolderToArchive/FolderB/FileA OK
Adding /temp/FolderToArchive/FolderB/FileC OK
Adding /temp/FolderToArchive/FolderA OK
Adding /temp/FolderToArchive/FolderB OK
Locking archive
Done
检查压缩包文件列表会包含压缩时绝对路径的所有文件夹, 绝对路径中的文件夹都会完整保存进去. 文件夹层数会非常多, 极其不推荐
路径为: /temp/FolderToArchive/
, 压缩包内路径为 temp/FolderToArchive/
[root@server WorkFolder]# rar l acesheep.rar
RAR 6.10 Copyright (c) 1993-2022 Alexander Roshal 24 Jan 2022
Registered to WinRAR
Archive: acesheep.rar
Details: RAR 5, lock
Attributes Size Date Time Name
----------- --------- ---------- ----- ----
-rw-r--r-- 0 2022-03-28 22:44 temp/FolderToArchive/File2
-rw-r--r-- 0 2022-03-28 22:44 temp/FolderToArchive/File1
-rw-r--r-- 0 2022-03-28 22:44 temp/FolderToArchive/FolderA/FileX
-rw-r--r-- 0 2022-03-28 22:44 temp/FolderToArchive/FolderA/FileY
-rw-r--r-- 0 2022-03-28 22:44 temp/FolderToArchive/FolderA/FileZ
-rw-r--r-- 0 2022-03-28 22:44 temp/FolderToArchive/File3
-rw-r--r-- 0 2022-03-28 22:44 temp/FolderToArchive/FolderB/FileB
-rw-r--r-- 0 2022-03-28 22:44 temp/FolderToArchive/FolderB/FileA
-rw-r--r-- 0 2022-03-28 22:44 temp/FolderToArchive/FolderB/FileC
drwxr-xr-x 0 2022-03-28 22:44 temp/FolderToArchive/FolderA
drwxr-xr-x 0 2022-03-28 22:44 temp/FolderToArchive/FolderB
----------- --------- ---------- ----- ----
0 11
- 命令稍作修改, 加入
-ep1
参数
[root@server WorkFolder]# rar a -m5 -ma5 -md128MB -r -k -ep1 acesheep.rar /temp/FolderToArchive/
RAR 6.10 Copyright (c) 1993-2022 Alexander Roshal 24 Jan 2022
Registered to WinRAR
Creating archive acesheep.rar
Adding /temp/FolderToArchive/File2 OK
Adding /temp/FolderToArchive/File1 OK
Adding /temp/FolderToArchive/FolderA/FileX OK
Adding /temp/FolderToArchive/FolderA/FileY OK
Adding /temp/FolderToArchive/FolderA/FileZ OK
Adding /temp/FolderToArchive/File3 OK
Adding /temp/FolderToArchive/FolderB/FileB OK
Adding /temp/FolderToArchive/FolderB/FileA OK
Adding /temp/FolderToArchive/FolderB/FileC OK
Adding /temp/FolderToArchive/FolderA OK
Adding /temp/FolderToArchive/FolderB OK
Locking archive
Done
此时压缩包中直接包含了绝对路径子目录中的所有文件, 但是 FolderToArchive
却被排除了
我想要包括 FolderToArchive
该怎么办呢
[root@server WorkFolder]# rar l acesheep.rar
RAR 6.10 Copyright (c) 1993-2022 Alexander Roshal 24 Jan 2022
Registered to WinRAR
Archive: acesheep.rar
Details: RAR 5, lock
Attributes Size Date Time Name
----------- --------- ---------- ----- ----
-rw-r--r-- 0 2022-03-28 22:44 File2
-rw-r--r-- 0 2022-03-28 22:44 File1
-rw-r--r-- 0 2022-03-28 22:44 FolderA/FileX
-rw-r--r-- 0 2022-03-28 22:44 FolderA/FileY
-rw-r--r-- 0 2022-03-28 22:44 FolderA/FileZ
-rw-r--r-- 0 2022-03-28 22:44 File3
-rw-r--r-- 0 2022-03-28 22:44 FolderB/FileB
-rw-r--r-- 0 2022-03-28 22:44 FolderB/FileA
-rw-r--r-- 0 2022-03-28 22:44 FolderB/FileC
drwxr-xr-x 0 2022-03-28 22:44 FolderA
drwxr-xr-x 0 2022-03-28 22:44 FolderB
----------- --------- ---------- ----- ----
0 11
- 命令稍作修改, 删除绝对路径中的最后一个文件夹斜杠
/
TAB 自动补全目录的时候会在末尾给文件夹加入一个斜杠
[root@server WorkFolder]# rar a -m5 -ma5 -md128MB -r -k -ep1 acesheep.rar /temp/FolderToArchive
RAR 6.10 Copyright (c) 1993-2022 Alexander Roshal 24 Jan 2022
Registered to WinRAR
Creating archive acesheep.rar
Adding /temp/FolderToArchive/File2 OK
Adding /temp/FolderToArchive/File1 OK
Adding /temp/FolderToArchive/FolderA/FileX OK
Adding /temp/FolderToArchive/FolderA/FileY OK
Adding /temp/FolderToArchive/FolderA/FileZ OK
Adding /temp/FolderToArchive/File3 OK
Adding /temp/FolderToArchive/FolderB/FileB OK
Adding /temp/FolderToArchive/FolderB/FileA OK
Adding /temp/FolderToArchive/FolderB/FileC OK
Adding /temp/FolderToArchive/FolderA OK
Adding /temp/FolderToArchive/FolderB OK
Adding /temp/FolderToArchive OK
Locking archive
Done
此时查看压缩包文件列表, 竟然是想要目录结构
[root@server WorkFolder]# rar l acesheep.rar
RAR 6.10 Copyright (c) 1993-2022 Alexander Roshal 24 Jan 2022
Registered to WinRAR
Archive: acesheep.rar
Details: RAR 5, lock
Attributes Size Date Time Name
----------- --------- ---------- ----- ----
-rw-r--r-- 0 2022-03-28 22:44 FolderToArchive/File2
-rw-r--r-- 0 2022-03-28 22:44 FolderToArchive/File1
-rw-r--r-- 0 2022-03-28 22:44 FolderToArchive/FolderA/FileX
-rw-r--r-- 0 2022-03-28 22:44 FolderToArchive/FolderA/FileY
-rw-r--r-- 0 2022-03-28 22:44 FolderToArchive/FolderA/FileZ
-rw-r--r-- 0 2022-03-28 22:44 FolderToArchive/File3
-rw-r--r-- 0 2022-03-28 22:44 FolderToArchive/FolderB/FileB
-rw-r--r-- 0 2022-03-28 22:44 FolderToArchive/FolderB/FileA
-rw-r--r-- 0 2022-03-28 22:44 FolderToArchive/FolderB/FileC
drwxr-xr-x 0 2022-03-28 22:44 FolderToArchive/FolderA
drwxr-xr-x 0 2022-03-28 22:44 FolderToArchive/FolderB
drwxr-xr-x 0 2022-03-28 22:44 FolderToArchive
----------- --------- ---------- ----- ----
0 12
- 可是文件夹中包含空格, 特殊字符. 打包的时候我想重命名文件夹该怎么办呢
缝合怪 -ep1
和 -ap<path>
参数
新文件夹名称 RenameFolder
[root@server WorkFolder]# rar a -m5 -ma5 -md128MB -r -k -ep1 -apRenameFolder acesheep.rar /temp/FolderToArchive/
RAR 6.10 Copyright (c) 1993-2022 Alexander Roshal 24 Jan 2022
Registered to WinRAR
Creating archive acesheep.rar
Adding /temp/FolderToArchive/File2 OK
Adding /temp/FolderToArchive/File1 OK
Adding /temp/FolderToArchive/FolderA/FileX OK
Adding /temp/FolderToArchive/FolderA/FileY OK
Adding /temp/FolderToArchive/FolderA/FileZ OK
Adding /temp/FolderToArchive/File3 OK
Adding /temp/FolderToArchive/FolderB/FileB OK
Adding /temp/FolderToArchive/FolderB/FileA OK
Adding /temp/FolderToArchive/FolderB/FileC OK
Adding /temp/FolderToArchive/FolderA OK
Adding /temp/FolderToArchive/FolderB OK
Locking archive
Done
这样压缩包内就是新的文件夹名称了, 完美!
[root@server WorkFolder]# rar l acesheep.rar
RAR 6.10 Copyright (c) 1993-2022 Alexander Roshal 24 Jan 2022
Registered to WinRAR
Archive: acesheep.rar
Details: RAR 5, lock
Attributes Size Date Time Name
----------- --------- ---------- ----- ----
-rw-r--r-- 0 2022-03-28 22:44 RenameFolder/File2
-rw-r--r-- 0 2022-03-28 22:44 RenameFolder/File1
-rw-r--r-- 0 2022-03-28 22:44 RenameFolder/FolderA/FileX
-rw-r--r-- 0 2022-03-28 22:44 RenameFolder/FolderA/FileY
-rw-r--r-- 0 2022-03-28 22:44 RenameFolder/FolderA/FileZ
-rw-r--r-- 0 2022-03-28 22:44 RenameFolder/File3
-rw-r--r-- 0 2022-03-28 22:44 RenameFolder/FolderB/FileB
-rw-r--r-- 0 2022-03-28 22:44 RenameFolder/FolderB/FileA
-rw-r--r-- 0 2022-03-28 22:44 RenameFolder/FolderB/FileC
drwxr-xr-x 0 2022-03-28 22:44 RenameFolder/FolderA
drwxr-xr-x 0 2022-03-28 22:44 RenameFolder/FolderB
----------- --------- ---------- ----- ----
0 11
完整帮助
RAR 6.10 Copyright (c) 1993-2022 Alexander Roshal 24 Jan 2022
Registered to WinRAR
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[1,2] Alternate 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
ep Exclude paths from names
ep1 Exclude base directory from names, 压缩包第一层直接是文件夹内容
ep2 默认值, 不用指定
ep3 Expand paths to full including the drive letter
ep4<path> Exclude the path prefix from names
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,n,p,q] Display or disable messages
ierr Send all messages to stderr
ilog[name] Log errors to file
inul Disable all messages
isnd[-] Control notification sounds
iver Display the version number
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
me[par] Set encryption parameters
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[a] Process symbolic links as the link [absolute paths]
op<path> Set the output path for extracted files
or Rename files automatically
ow Save or restore file owner and group
p[password] Set 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[mcao]<d> Process files modified after <d> YYYYMMDDHHMMSS date
tb[mcao]<d> Process files modified before <d> YYYYMMDDHHMMSS date
tk Keep original archive time
tl Set archive time to latest file
tn[mcao]<t> Process files newer than <t> time
to[mcao]<t> Process files older than <t> time
ts[m,c,a,p] Save or restore time (modification, creation, access, preserve)
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
How to Open, Extract and Create RAR Files in Linux
Switch -V
WinRAR storing file paths [closed]