To update or upgrade your Bash version on macOS, you can follow these steps:
Open the Terminal application.
Install the latest version of Bash using Homebrew by running the following command:
brew install bash
After the installation is complete, the new version of Bash will be located at
/usr/local/bin/bash. You can verify its location by running the command:
ls -l /usr/local/bin/bash
Ensure that the output shows the correct path.
If the new version of Bash is not listed in the
/etc/shellsfile, you need to append it. Execute the following command:
sudo -i echo /usr/local/bin/bash >> /etc/shells
Set the default shell to the new version of Bash by running the
chsh -s /usr/local/bin/bash
To confirm that the new version of Bash is installed and set as the default shell, use either of the following commands:
You should see output similar to the following:
GNU bash, version 5.0.11(1)-release (x86_64-apple-darwin18.6.0) Copyright (C) 2019 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html> This is free software; you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law.
By following these steps, you can update or upgrade your Bash version on macOS, regardless of the version you are using.