How to display the sum of n numbers entered from command line

 

Linux Bash Script

#Bash script to accept n numbers as command line arguments and display the sum of n numbers

for i in `echo $@`
do
        let temp=$temp+$i
done

echo "Sum of Entered number is: $temp"

 

 

Execute the Linux Script

./3_display_sum_of_numbers.sh 34 56 12

 

Output of Linux Script

102