In bash script
if [ 1 ]
then
echo "Yes"
else
echo "No"
fi
Output: Yes It represent that '1' is treated as true value.
But in code:
word = Linux
letter= nuxi
if echo "$word" | grep -q "$letter"
then
echo "Yes"
else
echo "No"
fi
Output:No
But echo "$word" | grep -q "$letter"
will return 1, why the result is No.
how the keyword “if” test the value returned by the command after "if"?