首页 > 代码库 > 解决MacOS下readlink: illegal option -- f

解决MacOS下readlink: illegal option -- f

Mac下的readlink没有-f参数,诸如screenfetch又会去调用readlink -f,于是每次都会出现:

readlink: illegal option -- f
usage: readlink [-n] [file ...]

很是烦人,解决方案如下:
1.安装coreutils:

brew install coreutils

2.设置环境变量,编辑~/.bash_profile,添加:

export PATH="/usr/local/opt/coreutils/libexec/gnubin:$PATH"

3.创建别名,使用greadlink替代readlink,同样是编辑~/.bash_profile,添加:

alias readlink=greadlink

解决MacOS下readlink: illegal option -- f