This shellscript sum up the numbers from arg1 to arg2.
#!/bin/sh
i=0
sum=0
if [ $# -eq 0 ]; then
echo "No input parameter!"
elif [ $# -eq 1 ]; then
echo "Plese input 2 parameters!"
else
i=$1
for i in seq $1 $2; do
sum=`expr $sum + $i`
done
echo "$1 + ... + $2 = $sum"
fi
exit 0
コメント