Logo 
Search:

Unix / Linux / Ubuntu Articles

Submit Article
Home » Articles » Unix / Linux / Ubuntu » Homework HelpRSS Feeds

Shell Script to find out the sum of the given numbers using command line argument

Posted By: Keira Hughes     Category: Unix / Linux / Ubuntu     Views: 24345

Write a Shell Script to find out the sum of the given numbers using command line argument.

Code for Shell Script to find out the sum of the given numbers using command line argument in Unix / Linux / Ubuntu

sum=0
for i in $*
do
    sum=`expr $sum + $i`
done
echo "Summation of "$#" no. is: "$sum



OUTPUT
***********
[04mca58@LINTEL 04mca58]$  sh sum.sh 10 20
Summation of 2 no. is: 30

  
Share: 



Keira Hughes
Keira Hughes author of Shell Script to find out the sum of the given numbers using command line argument is from London, United Kingdom.
 
View All Articles

Related Articles and Code:


 
Please enter your Comment

  • Comment should be atleast 30 Characters.
  • Please put code inside [Code] your code [/Code].

 
No Comment Found, Be the First to post comment!