Remove "No LSB modules are available." message from 'lsb_release -a' command

Stumbled upon this via search results. Doesn't the following work across your systems?

$ lsb_release -sr
20.04

That gives you the short release output.

As you write that you want a variable.

export RELEASE=$(lsb_release -sr)

Should do exactly what you would need, or?


That message is sent to standard error, so redirecting that to /dev/null will get rid of it (along with any other error message produced by lsb_release):

lsb_release -ar 2>/dev/null | grep -i release | cut -s -f2

Tags:

Linux

Bash

Ubuntu