Alex_DeLarge
Alex_DeLarge

Reputation: 345

bash --version. Where this info are stored?

In which file are stored the info about the command bash --version ? I've tried in some directories like /bin or /var, /etc, but without results...

I need both for Linux and MAC OS x. Thanks!

Upvotes: 1

Views: 72

Answers (2)

Andrey Tyukin
Andrey Tyukin

Reputation: 44918

Do you have any reason to believe that it is not hard-coded in the bash-executable itself?

To find out which bash is used, run

which bash

For me, it gives /bin/bash. Now, to see whether the executable has any string-like byte sequences in it that contain the substring "version", run

strings /bin/bash | grep version

On this machine, it gives:

shell_version_string
build_version
sccs_version
rl_library_version
rl_do_lowercase_version
show_shell_version
rl_readline_version
dist_version
GNU bash, version %s-(%s)
GNU bash, version %s (%s)
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
@(#)Bash version 4.3.48(1) release GNU
display-shell-version
      -l    do not print tilde-prefixed versions of directories relative
    HOSTTYPE    The type of CPU this version of Bash is running under.
    OSTYPE  The version of Unix this version of Bash is running on.
    version, type `enable -n test'.
do-lowercase-version
.gnu.version
.gnu.version_r

Thus, "Bash version 4.3.48" is hard-coded in the executable as an ordinary string.

Upvotes: 1

Cyrus
Cyrus

Reputation: 88654

strings $(which bash) | grep "Bash version"

Output (e.g.):

@(#)Bash version 4.3.48(1) release GNU

Upvotes: 1

Related Questions