我正在尝试编写一个脚本,将三个指定的参数一起添加,如果没有参数输出:"无参数".
麻烦的是,即使有三个参数,也总是输出"无参数".
我是shell脚本的新手.
这是我的脚本:
#!/bin/sh
if [[("$#"==0)]]; then
echo "No arguments specified"
exit 1
fi
sum=0
sum=$(expr $1 + $2 + $3)
echo "$sum"
exit 0
Run Code Online (Sandbox Code Playgroud)