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