Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

Which is the shortest way to get the variable $DISTRIB_CODENAME from /etc/lsb-release?

I want to make this somewhat shorter:

$ sudo add-apt-repository \
  "deb http://some-repo/ubuntu $(grep CODENAME lsb-release |sed s/^.*=//g) main"
share|improve this question

2 Answers 2

up vote 5 down vote accepted

You can source that file in bash (or any Bourne-like shell) to set them as shell variables:

source /etc/lsb-release
sudo add-apt-repository "deb http://some-repo/ubuntu $DISTRIB_CODENAME main"
share|improve this answer

The command lsb-release has an option to display codename according to the distribution release:

apt-get install lsb-release
lsb_release -c -s

So you can try to rewrite it like this:

sudo add-apt-repository "deb http://some-repo/ubuntu $(lsb_release -c -s) main"

For details, check man lsb_release.

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.