Sample Header Ad - 728x90

Can't compare lsb_release result to string in Bash

1 vote
3 answers
1542 views
I'm doing something wrong on the string comparison below. It works if I set a variable and compare that, but I can't copy the value to a string. Does anyone know what's wrong? $ if [ "$(lsb_release -i)" = "Distributor ID: RedHatEnterpriseClient" ]; then echo yes; else echo no; fi no $ lsb_release -i Distributor ID: RedHatEnterpriseClient $ var="$(lsb_release -i)" $ if [ "$(lsb_release -i)" = "$var" ]; then echo yes; else echo no; fi yes
Asked by Aido (164 rep)
Jul 6, 2017, 02:15 PM
Last activity: Jul 6, 2017, 03:50 PM