Sample Header Ad - 728x90

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

9 votes
3 answers
21164 views
I try to write a script to get the version of my distro so that I can pass it to a variable. The following command is what I wrote to achieve the result.
lsb_release -ar | grep -i release | cut -s -f2
The unwanted output:
No LSB modules are available.
18.04
As you can see, the No LSB modules are available message is the unwanted part. Since I prefer my script to be portable across servers, I don't want to install any extra packages beside utilizing the lsb_release -a command.
Asked by vincent pham (311 rep)
Jan 7, 2020, 12:33 AM
Last activity: Jun 9, 2023, 05:09 PM