Find the sum of some numbers taken as command line arguments
Find the sum of some numbers taken as command line arguments Shell Script: clear n=$# sum=0 for((i=1;i<=$n;i++)) do sum=`expr $sum + $1` shift 1 done echo The sum is $sum OUTPUT [csma@localhost ~]$ sh add.sh 1 2 3 4 The sum is 10
Tags:
Shell Script
0 comments