I am writing a bash script which has a subtask of printing the Ubuntu name on which the system is running. I did:
ubuntu_ver=$(lsb_release -a | grep Description | cut -d":" -f2)
echo $ubuntu_ver
Ubuntu 12.04 LTS got stored in variable ubuntu_ver but and additional line got printed on the top. The output was:
No LSB modules are available.
Ubuntu 12.04.4 LTS
How to prevent the 'No LSB modules...' from getting printed?
In fact this line gets printed whenever I try to store something in a variable from the command 'lsb_release -a'.
In fact this line gets printed whenever I try to store something in a variable from the command
lsb_release -a
This suggests that the offending line is actually an error message. Discard it:
ubuntu_ver=$(lsb_release -a 2>/dev/null | grep Description | cut -d":" -f2)