I am doing a string comparison between a variable and a constant. The result of the comparison, either true
or false
, is assigned to another variable.
LABEL=$("${INPUT}" == "flag");
However, I am failing. Any suggestion?
You can use expr
:
INPUT='flag'
LABEL=$(expr "${INPUT}" == "flag")
echo "$LABEL"
1
INPUT='flab'
LABEL=$(expr "${INPUT}" == "flag")
echo "$LABEL"
0