How do I check virtualbox version from CLI
To print or view the current VirtualBox version you should use below command:
vboxmanage --version
which will then print the current version as seen below;
Refer 8.2. Command overview at the official VirtualBox site for more.
To print the version using the script, see below:
#!/bin/bash
echo $(vboxmanage --version)
Hope it helps.
You can try this,
virtualbox --help | head -n 1 | awk '{print $NF}'
or
$ echo $(virtualbox --help | head -n 1 | awk '{print $NF}')
4.3.6
How it works
Step -1
virtualbox --help
gives you a long output saying many options etc. But its very first lines are like,
Oracle VM VirtualBox Manager 4.3.6
(C) 2005-2013 Oracle Corporation
All rights reserved.
...
Step -2
| head -n 1
|
is called pipe. It has great application in command line. It passes the whole expression to the next command head
. head -n 1
prints the first line only. see man head
for more. At this stage output is only
Oracle VM VirtualBox Manager 4.3.6
Step -3
| awk '{print $NF}'
Again the remaining things are passed to awk
. At this stage awk
sees the whole line as combinations of few fields separated by space and prints only the last field of the above expression. So you get the version only. See man awk
for more.
you could know the version of package installed with dpkg and grep with piping
dpkg -l | grep virtualbox | awk '{print $3}'