最佳答案
这里我的问题是找出 if 语句中使用单括号[]和双括号[[]]的区别。
#!/bin/bash
vara=08;
varb=10;
## single bracket in if statment is working.
if [ $vara -lt $varb ]; then
echo "yes";
else
echo "no";
fi
## double brackets in if statment is not working; throwing an error like below.
## [[: 08: value too great for base (error token is "08")
if [[ $vara -lt $varb ]]; then
echo "yes";
else
echo "no";
fi