我想比较两个数字,但比较不起作用
read x
read y
if["$x" -lt "$y"]
then
echo "X is less than Y"
elif["$x" -gt "$y"]
then
echo "X is greater than Y"
elif["$x" -eq "$y"]
then
echo "X is equal to Y"
fi
当输入为x = 5
和y = 2
我得到以下运行时错误:
solution.sh: line 4: if[5 -lt 2]: command not found
solution.sh: line 5: syntax error near unexpected token `then'
solution.sh: line 5: `then