In below code, whatever the letter i pass to test , the result is all wrong. Can someone help me, thanks.
bash# cat test.sh
#!/bin/bash
#Using eq
if [[ ${1^^} -eq "D" ]]
then
echo "Using eq: D"
else
echo "Using eq: Not D"
fi
#Using ==
if [[ ${1^^} == "D" ]]
then
echo "Using ==: D"
else
echo "Using ==: Not D"
fi
bash:# ./test.sh o
Using eq: D
Using ==: Not D
In a interactive shell, the result is still wrong: bash # letter='o' bash # if [[ ${letter^^} -eq 'D' ]]
> then
> echo "D"
> else
> echo "not D"
> fi
D