5

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
8

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
7

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

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.