前一段时间,后端同事传给我一个代码压缩包,是公司以前的前后端不分离的代码,好像是jsp啥的,我需要重构前端部分,想想就头大,但是领导催的急啊,没办法,硬着头皮也得上。OK,下载,解压,开干。。。
万万没想到,遇到的第一个问题竟然是。。。解压
解压报错:
说明一下,我使用的解压工具是MacZip
,号称最好用的mac
解压神器,但是呢。。。呃,情况就是这么个情况,下面我们的目标就是解决这个问题。
网上翻找一遍,偶然看到,还可以使用终端命令解压,再一看,还挺简单,顿时豁然开朗,啥也不说了,撸起。
首先,我们需要安装一个工具,叫做unrar
,这个工具需要使用brew
安装,brew
想必大家都清楚,但是实际常用的估计不多,我就是这样,很久未用,导致版本偏低,安装unrar
时报错:No available formula or cask with the name "unrar".
于是升级brew
,步骤如下:
1、先更新brew
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
2、更新国内源
// 更新Homebrew
cd "$(brew --repo)"
git remote set-url origin https://mirrors.ustc.edu.cn/brew.git
// 更新Homebrew-core
cd "$(brew --repo)/Library/Taps/homebrew/homebrew-core"
git remote set-url origin https://mirrors.ustc.edu.cn/homebrew-core.git
// 更新Homebrew-cask(最重要的一步,很多更新完国内源依然卡就是没更新这个)
cd "$(brew --repo)"/Library/Taps/homebrew/homebrew-cask
git remote set-url origin https://mirrors.ustc.edu.cn/homebrew-cask.git
3、更新HOMEBREW_BOTTLE_DOMAIN
zsh
用户
echo 'export HOMEBREW_BOTTLE_DOMAIN=https://mirrors.ustc.edu.cn/homebrew-bottles/' >> ~/.zshrc
source ~/.zshrc
bash
用户
echo 'export HOMEBREW_BOTTLE_DOMAIN=https://mirrors.ustc.edu.cn/homebrew-bottles/' >> ~/.bash_profile
source ~/.bash_profile
4、更新库
brew update -v
或
brew update-reset
到这里,Homebrew
更新完毕,接下来,我们继续安装unrar
,使用命令brew install unrar
,报错没有之前多了,但是一个核心报错仍然存在:No available formula or cask with the name "unrar".
,于是继续搜索,发现很多人遇到这个问题,但是具体原因还是不确定,总之就是unrar
这个包现在underfined
,万能的网友又提供了另外一种方法:
brew install carlocab/personal/unrar
这是大佬备份的一份包,git地址放出:github.com/Homebrew/di…
去打星吧。
到这里,unrar
包已经安装完毕,赶紧试一下:
- 进到需要解压的文件夹:
cd 'target_path'
- 解压
.rar
文件到当前文件夹:unrar e 'file_name'
- 解压
.rar
文件到指定路径:unrar x 'file_name' 'target_path'
- 解压带密码的
.rar
文件到当前文件夹:unrar e -p'123' 'file_name'
- 解压带密码的
.rar
文件到指定文件夹:unrar x -p'123' 'file_name' 'target_path'
PS:命令中的x
和e
作用一样
以上亲测有效。
大佬们如果有更好的方法欢迎前来讨论