Unix shell 脚本:
我有 7 个函数需要作为命令行输入执行,我尝试使用下面的代码它没有执行函数。
if [ "$VAL" == "1" ]
then
fun1
elif [ "$VAL" == "2" ]
then
fun2
elif [ "$VAL" == "3" ]
then
fun3
elif [ "$VAL" == "4"]
then
fun4
elif [ "$$VAL" ==" 5" ]
then
fun5
elif [ "$VAL" == "6" ]
then
fun6
elif [ "$VAL" == "7" ] then
fun7
else
echo -e "Invalid input.............\n"
Help
exit
fi
输出:
Usage: ./script $VAL
# ./script 2
Invalid input...........