Mac 升级bash 到4版本

  • A+
所属分类:MAC
[lookback@LookBack-MBP ~]$ /bin/bash --version
GNU bash, version 3.2.57(1)-release (x86_64-apple-darwin17)
Copyright (C) 2007 Free Software Foundation, Inc.
[lookback@LookBack-MBP ~]$ 
# 安装brew
[lookback@LookBack-MBP ~]$ /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
# 安装bash
[lookback@LookBack-MBP ~]$ brew install bash
#替换bash
[lookback@LookBack-MBP ~]$ sudo mv /bin/bash /bin/bash.origin
[lookback@LookBack-MBP ~]$ sudo ln -s /usr/local/opt/bash/bin/bash /bin/bash
# 由于本mac版本下的sh并不是直接链接bash,而是bash的一个文件拷贝。因此,还要替换默认的sh指向的命令为bash,如下:
[lookback@LookBack-MBP ~]$ sudo mv /bin/sh /bin/sh.origin
[lookback@LookBack-MBP ~]$ sudo ln -s /usr/local/opt/bash/bin/bash /bin/sh

2. 验证 通过bash和sh命令查看版本:

[lookback@LookBack-MBP ~]$ bash --version
GNU bash,版本 4.4.23(1)-release (x86_64-apple-darwin17.5.0)
Copyright (C) 2016 Free Software Foundation, Inc.
许可证 GPLv3+: GNU GPL 许可证第三版或者更新版本 <http://gnu.org/licenses/gpl.html>

本软件是自由软件,您可以自由地更改和重新发布。
在法律许可的情况下特此明示,本软件不提供任何担保。
[lookback@LookBack-MBP ~]$ 
lookback

发表评论

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen: