Bash - Version

> Procedural Languages > Bash Shell and (Unix|Linux) Utilities (XCU)

1 - About

Version of Bash

Advertising

3 - Variable

The version information can be found in the following shell variable

3.1 - BASH_VERSION

Expands to a string describing the version of this instance of bash.

echo ${BASH_VERSION}
4.3.46(1)-release

3.2 - BASH_VERSINFO

A readonly array variable whose members hold version information for this instance of bash. The values assigned to the array members are as follows:

  • BASH_VERSINFO[0] The major version number (the release).
  • BASH_VERSINFO[1] The minor version number (the version).
  • BASH_VERSINFO[2] The patch level.
  • BASH_VERSINFO[3] The build version.
  • BASH_VERSINFO[4] The release status (e.g., beta1).
  • BASH_VERSINFO[5] The value of MACHTYPE.

Example

  • The major version number (the release).
echo ${BASH_VERSINFO[0]}
4
  • The minor version number (the version).
echo ${BASH_VERSINFO[1]}
3
  • The patch level
echo ${BASH_VERSINFO[2]}
46
  • The build version
echo ${BASH_VERSINFO[3]}
1
  • The release status (e.g., beta1)
echo ${BASH_VERSINFO[4]}
release
  • The value of MACHTYPE
echo ${BASH_VERSINFO[5]}
x86_64-pc-linux-gnu
Advertising

4 - Documentation / Reference