Fadi Fadi - 4 months ago 12
Bash Question

Print out only the version of Ubuntu

I need to echo only the version of Ubuntu in BASH. So let's say that I am on Ubuntu Trusty (14.04), I want to be able to print out just the

14.04
part.

Answer

The easiest way to do this is lsb_release -sr.

For example, on my Ubuntu 16.04 machine:

$ lsb_release -sr
16.04