试图在ShellScript上测试函数,但我一直收到答案:"未找到命令";
# Trying to create functions that receives arguments e have returns
# The function will receive two values and say hwo is bigger
bigger () {
if [$1 -gt $2]
then
return $1
else
return $2
fi
}
echo "Size does matter!!!!"
echo " "
printf "Enter the first number: - "
read data1
echo " "
printf "Enter the second number: - "
read data2
echo " "
printf "The bigger number is: - "
bigger $data1 $data2
我得到的结果是:
在此处输入图像描述
出现语法错误,bash试图将[1
解释为命令。添加空格以修复此
更改
if [$1 -gt $2]
至
if [ "$1" -gt "$2" ]