当我在终端上输入超过一个参数时,请继续处理这个问题:
./学习1 2
我从while循环中总结了出来,但是注释掉的东西还没有找到原因。
#!/bin/ksh
#
count=$#
if test $count -lt 1
then
echo "Enter at least 1 number"
exit
elif test $count -gt 9
then
echo "Enter max 9 numbers"
exit
else
echo "Parameter check: PASSED"
fi
set -A numbers $@
first=${numbers[0]}
if test $count -eq 1
then
echo "$first = $first"
exit
else
sum=$first
printf "$first + "
fi
while test "$count" -gt 1
do
shift
first=${numbers[0]}
((sum = sum + first))
if test $count -gt 2
then
printf "$first + "
else
printf "$first = $sum"
fi
((count = count - 1)
done 它基本上是一个程序,接收用户的输入.也就是说,从屏幕上输入1,2,3,然后加在一起给出一个和
发布于 2014-05-18 20:36:19
done之前的台词,
((count = count - 1)有两个开口,但只有一个关闭支撑。
https://stackoverflow.com/questions/23726568
复制相似问题