Shell 脚本的功能问题

Problems with function on Shell Script

尝试在 ShellScript 上测试功能,但我不断收到答案:“找不到命令”

# Trying to create functions that receives arguments e have returns
# The function will receive two values and say hwo is bigger

bigger () {
if [ -gt ]
then
   return 
else
   return 
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

我得到的结果是:

enter image description here

您有语法错误,bash 试图将 [1 解释为命令。 添加空格以解决此问题

改变

if [ -gt ]

if [ "" -gt "" ]