Find the value of 1+2+3+4+...... taken as command line arguments
Find the value of 1+2+3+4+...... taken as command line arguments Shell Script: clear str=$1 IFS=+ set $str n=$# s=0 for((i=1;i<=$n;i++)) do s=`expr $s + $1` shift 1 done echo the summation is $s OUTPUT: [csma@localhost ~]$ sh addifs.sh 1+2+4+5 the summation is 12
Tags:
Shell Script
0 comments