Skip to content

MacOS 中压缩解压rar文件

约 853 字大约 3 分钟

2025-02-07

当我们需要在WindowsMacOS直接传输文件时,经常会遇到rar格式的压缩文件,而MacOS默认是不支持rar格式的压缩文件的,所以我们需要安装一些工具来支持rar格式的压缩文件。

MacOS中,有多种方式可以解压rar文件。

AppStore

可以在AppStore中搜索The Unarchiver或其他支持rar解压的应用即可

Homebrew

使用Homebrew安装支持rar的工具,如unar工具

手动安装工具

Homebrew如果没有找到合适的解压工具,则可以查找一些支持rar解压的工具,如unrar

unrar

unrar 是一个非开源的工具,因此 Homebrew 默认不提供它,但我们可以在RARLab 官方网站下载对应系统的unrar工具包。

下载对应的软件包,这里我在MacOS中下载的是RAR for macOS ARM 7.10 beta 3

下载之后解压就得到了rar文件夹,里面有两个程序rarunrar,分别负责压缩和解压。

$ cd rar
$ ll
total 2960
-rw-r--r--@ 1 matias  staff   2.7K  2  6 21:55 acknow.txt
-rwxr-xr-x@ 1 matias  staff   238K  2  6 21:55 default.sfx
-rw-r--r--@ 1 matias  staff   6.6K  2  6 21:55 license.txt
-rw-r--r--@ 1 matias  staff   3.2K  2  6 21:55 order.htm
-rwxr-xr-x@ 1 matias  staff   677K  2  6 21:55 rar
-rw-r--r--@ 1 matias  staff   106K  2  6 21:55 rar.txt
-rw-r--r--@ 1 matias  staff   1.2K  2  6 21:55 rarfiles.lst
-rw-r--r--@ 1 matias  staff   692B  2  6 21:55 readme.txt
-rwxr-xr-x@ 1 matias  staff   385K  2  6 21:55 unrar
-rw-r--r--@ 1 matias  staff    37K  2  6 21:55 whatsnew.txt

使用全路径来解压文件。

$ ~/Downloads/rar/unrar x ~/Downloads/agent_update_20250124.rar

UNRAR 7.10 beta 3 freeware      Copyright (c) 1993-2025 Alexander Roshal


Extracting from /Users/matias/Downloads/agent_update_20250124.rar

Extracting  brainstorm.py                                             OK
Extracting  intro_creator.py                                          OK
Extracting  plot_crafter.py                                           OK
Extracting  polisher.py                                               OK
Extracting  writing_fanfic.py                                         OK
Extracting  writing_fp.py                                             OK
Extracting  writing_planner_npfpcoh.py                                OK
Extracting  writing_planner_nptpcoh.py                                OK
Extracting  writing_tp.py                                             OK
Extracting  writing_tp_lp.py                                          OK
Extracting  agent_for_test.py                                         OK
Extracting  book_breakdown_character.py                               OK
Extracting  book_breakdown_story.py                                   OK
Extracting  book_breakdown_story_structured.py                        OK
All OK

注意 解压出的文件,在运行指令的路径下。

后面我将rar这文件夹,移动到了$HOME/tools路径下,方便管理。

unrar添加到PATH中,或添加软链接到bin路径下,方便使用。

$ sudo ln -s $HOME/tools/rar/unrar /usr/local/bin/unrar
Password:
$ which unrar
/usr/local/bin/unrar

同理添加rar

$ sudo ln -s $HOME/tools/rar/rar /usr/local/bin/rar
$ which rar
/usr/local/bin/rar

解压测试

$ unrar x ../agent_update_20250124.rar
UNRAR 7.10 beta 3 freeware      Copyright (c) 1993-2025 Alexander Roshal


Extracting from ../agent_update_20250124.rar

Extracting  brainstorm.py                                             OK
Extracting  intro_creator.py                                          OK
Extracting  plot_crafter.py                                           OK
Extracting  polisher.py                                               OK
Extracting  writing_fanfic.py                                         OK
Extracting  writing_fp.py                                             OK
Extracting  writing_planner_npfpcoh.py                                OK
Extracting  writing_planner_nptpcoh.py                                OK
Extracting  writing_tp.py                                             OK
Extracting  writing_tp_lp.py                                          OK
Extracting  agent_for_test.py                                         OK
Extracting  book_breakdown_character.py                               OK
Extracting  book_breakdown_story.py                                   OK
Extracting  book_breakdown_story_structured.py                        OK
All OK
$ ll
total 1288
-rw-r--r--  1 matias  staff   7.2K  1 23 17:49 agent_for_test.py
-rw-r--r--  1 matias  staff    22K  1 22 18:27 book_breakdown_character.py
-rw-r--r--  1 matias  staff   125K  1 23 15:32 book_breakdown_story.py
-rw-r--r--  1 matias  staff    73K  1 23 15:33 book_breakdown_story_structured.py
-rw-r--r--  1 matias  staff    66K  1 23 15:34 brainstorm.py
-rw-r--r--  1 matias  staff    32K  1 23 15:57 intro_creator.py
-rw-r--r--  1 matias  staff    44K  1 24 13:44 plot_crafter.py
-rw-r--r--  1 matias  staff    25K  1 23 15:57 polisher.py
-rw-r--r--  1 matias  staff    30K  1 23 16:03 writing_fanfic.py
-rw-r--r--  1 matias  staff    37K  1 23 16:03 writing_fp.py
-rw-r--r--  1 matias  staff    45K  1 23 16:04 writing_planner_npfpcoh.py
-rw-r--r--  1 matias  staff    32K  1 23 15:32 writing_planner_nptpcoh.py
-rw-r--r--  1 matias  staff    39K  1 23 15:32 writing_tp.py
-rw-r--r--  1 matias  staff    40K  1 23 15:32 writing_tp_lp.py

参考

RARLab 官方网站