Avatar of Swaminathan K
Swaminathan K
Flag for India asked on

calling function in echo command

Hi Team,

Below is the shell script i have written , I have written a function to add two numbers and calling that function as part of echo statement. But iam not getting the results.

#!/bin/bash


if [ $# -ne 2 ]
then
        echo " Wrong number of arguments. Usage: scriptname number1 number2"
        exit 1
fi


add()
{
        sum=$[  $1 + $2 ]
}

echo " The Sum of $1 + $2 is : S(   add )"

calling the script addnum 10 20

Any help is really appreciated.


~                                                                              
~                                                                              
~                                                                              
~
Linux

Avatar of undefined
Last Comment
ozo

8/22/2022 - Mon
ASKER CERTIFIED SOLUTION
ozo

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
Your help has saved me hundreds of hours of internet surfing.
fblack61