I'm trying to compare a substring of one string variable to a whole variable, and it just always comes out as false.
COMP='<'
if [[ '${SNIP:0:1}' = '$COMP' ]] ;then
LENG=6
elif [[ '${SNIP:1:1}' = '$COMP' ]] ;then
LENG=7
else
LENG=8
fi
echo $SNIP
echo ${SNIP:0:1}
echo ${SNIP:1:1}
echo $COMP
echo $LENG
I've tried as well with just comparing the substrings with '<', but this instead always returns true.
I would expect the output to be
3<a
<
<
7
but the output is
3<a
<
<
8
and I don't know what is messing up. Please help. Thank you.