How do i check the version of bash using $BASH_VERSION?



  • Man page for bash.

    There the --version good if you just want to see the version.

    bash --version
    GNU bash, version 4.4.19(1)-release (x86_64-pc-linux-gnu)
    Copyright (C) 2016 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.
    

    If you are hoping around to different user accounts as root user, one way of determining the shell type of the user is:

    $ echo $BASH_VERSION
    4.4.19(1)-release
    

    If it comes back blank or undefined, it's not a bash shell.

    If you switched shells on the command line from zsh to bash for instance and do echo $SHELL it gives you /usr/bin/zsh, which is your user shell but not the current shell.


Log in to reply
 

© Lightnetics 2024