Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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

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 6 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.