Using no external tools:
You can just source (the source command is a dot .) the /etc/os-release and you'll have access to all the variables defined there:
$ . /etc/os-release
$ echo "$VERSION"
14.04, Trusty Tahr
Edit. If you want to remove the 14.04, part (as asked by terdon), you could:
$ . /etc/os-release
$ read _ UBUNTU_VERSION_NAME <<< "$VERSION"
$ echo "$UBUNTU_VERSION_NAME"
Trusty Tahr
Note that this is a bit clunky, since on other distributions, the VERSION field can have different format. E.g., on my debian,
$ . /etc/os-release
$ read _ UBUNTU_VERSION_NAME <<< "$VERSION"
$ echo "$UBUNTU_VERSION_NAME"
(wheezy)
Then, you could imagine something like this (in a script):
#!/bin/bash
if [[ -r /etc/os-release ]]; then
. /etc/os-release
if [[ $ID = ubuntu ]]; then
read _ UBUNTU_VERSION_NAME <<< "$VERSION"
echo "Running Ubuntu $UBUNTU_VERSION_NAME"
else
echo "Not running an Ubuntu distribution. ID=$ID, VERSION=$VERSION"
fi
else
echo "Not running a distribution with /etc/os-release available"
fi