6

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
10

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
| improve this answer | |
9

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
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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