Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

(learning bash) I was trying to check the bash version so I typed /bin/bash -v.

That outputted a whole lot of text to the screen (contents of .bashrc, and other files sourced from it).

Could I have screwed up something (like overwriting some config files/setting incorrect environment variables etc.) due to that command?

I also can't find documentation on what the -v switch is for.

share|improve this question

3 Answers 3

up vote 40 down vote accepted

The -v parameter for bash stands for verbose, and instructs bash to print out as much information as possible about what it is doing. On startup, it will print out all the configuration it is reading in.

To print out the version information for bash, use bash --version.

share|improve this answer
    
Great! I also found the list of switches for bash. –  Zabba May 2 '11 at 17:21
8  
Alternatively, if you're already running a bash shell, you can output the content of the special BASH_VERSION variable. echo "$BASH_VERSION". There's also a special array (BASH_VERSINFO) containing each version number in separate elements. if ((BASH_VERSINFO[0] < 4)); then echo "Sorry, you need at least bash-4.0 to run this script." >&2; exit 1; fi –  geirha May 2 '11 at 20:42

When running bash (e.g. from gnome-terminal) you can check value of BASH_VERSION environment variable.

$ echo $BASH_VERSION
4.2.37(1)-release

If the value is empty, you are not running bash.

share|improve this answer
5  
This is better than just running bash --version, because it confirms that you are currently running bash, not just that you have bash installed on your system. –  Flimm Apr 11 '13 at 9:23
    
+1 bash --version does not show the bash you are currently using. –  gabeio Mar 6 at 1:38
    
Beware: A set BASH_VERSION does not ensure that you are running bash: export BASH_VERSION; csh -c 'echo $BASH_VERSION $SHELL $shell', so $BASH_VERSION may be set in csh as well –  Tino Nov 25 at 19:48

No, everything is alright. From man bash:

   --verbose
          Equivalent to  -v.

It is just not as silent as usual. Try

--version 

instead.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.