Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I only want one of the following values:

  • 11.10
  • oneiric

I've tried checking out lsb_release -r and uname -a, but the output is still verbose without using grep. This is the closest I've gotten to:

  • distribution name:
    grep -oP 'CODENAME=(.+)' -m 1 /etc/lsb-release | awk -F= '{ print $NF }'
  • version number:
    grep -oP '\d+\.\d+' -m 1 /etc/lsb-release
share|improve this question

2 Answers 2

For release:

$ lsb_release --release
Release:    11.04

For codename:

$ lsb_release --codename
Codename:   natty

To get just 11.04 or natty you can use cut. For example:

$ lsb_release --release | cut -f2
11.04

For everything:

$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 11.04
Release:    11.04
Codename:   natty
share|improve this answer
    
+1 missed posting answer by one second!!! :P –  Vineet Menon Apr 25 '12 at 5:07
up vote 3 down vote accepted

The easiest way is is to use -s or --short:

lsb_release -si 
#  Ubuntu

lsb_release -sr
#  11.04

lsb_release -sir
#  Ubuntu
#  11.04
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.