I am relatively new to bash.
I had bash 3 In my mac by default.
GNU bash, version 3.2.57(1)-release (x86_64-apple-darwin18)
Copyright (C) 2007 Free Softw
homebrew installs programs into /usr/local/bin
so if you want to use the version installed by homebrew you need to either run:
/usr/local/bin/bash --version
or ensure that /usr/local/bin
occurs before /bin
on your PATH, e.g.
export PATH=/usr/local/bin:PATH
If you have two versions of bash installed, you need to make sure you are running the right one. In a script you need a first line like:
#!/usr/local/bin/bash
(Adjust path as necessary for your installation.)
If you are interactive, make sure you are actually running the version of bash you expect, not just that it's the first 'bash' in your search path.
The bash -version
(or bash --version
) command tells you the version of Bash that you would get if you ran bash
.
But I'm guessing that you're not manually running bash
; rather, you're just opening the shell, which is probably still the older version of Bash. (It's quite possible, and not even that unusual, to have two copies of Bash installed on a system in different locations.) To check this, you can run echo "$BASH_VERSION"
to see the version of Bash that you're actual typing in.
To fix this, you will need to configure your machine to use the newer version of Bash as your shell. (Or you can just run bash
manually.)