Things about BASH

  1. What is Bash
    • Bash is a shell program that enables you to pass commands to the operating system (in this case Linux) and have them executed
  2. How does one check the version of the Bash shell

    • Checking the bash version helps Linux users in many cases, including troubleshooting and finding the currently available version in the system. If you are a regular bash user, it is good to check the bash version and keep it up to date as per the latest updates available. However, if you are a newbie in bash scripting, then you probably have never encountered a situation where you need to check the bash version.
    • The Simple Approach
      • The following command is the easiest way to know the bash version:

        bash –version

        checking-bash-versionFrom the above result, you can see the current bash version of the system is 5.2.21(1).Built in $BASH_VERSION variable
      • Another method to check the bash’s version is to enter the content of the bash shell’s variable as follows:

        echo $BASH_VERSION

        echo-to-check-the-bash-versionThe Shell Script
        • It is also possible to check the bash version through a shell script. First, create a new shell script using the nano command, create a new bash file named check-bash-version.sh, and make it executable using the chmod command:nano ~/check-bash-version.shchmod +x check-bash-version.sh

          Next, add the following lines to your script:

          #!/bin/bash echo”Checking the bash version….”echo “The Bash version is $BASH_VERSION !”

          shell-scripting-to-check-the-bash-versionNow, check the bash version by running the script as follows:./check-bash-version.sh

          executing-the-shell-scriptingUsing the Shortcut KeyMeanwhile, you can use the shortcut key ‘ Ctrl+X followed by ‘Ctrl+V’, and you may see the bash version on your screen as seen in the below image:key-board-shortcut-keyFrom the Package Manager
    • Through the package manager, you can simply run a single command to view the bash version.yum info bash (for CentOS/RHEL)pkg info bash (for FreeBSD)apk info bash (for Alpine Linux)apt info bash (for Ubuntu)

      apt-info-bash-scripting

Write a Comment

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.