We help IT Professionals succeed at work.

calling function in echo command

sam_2012
sam_2012 asked
on
64 Views
Last Modified: 2018-11-21
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.


~                                                                              
~                                                                              
~                                                                              
~
Comment
Watch Question

CERTIFIED EXPERT
Most Valuable Expert 2014
Top Expert 2015
Commented:
This problem has been solved!
(Unlock this solution with a 7-day Free Trial)
UNLOCK SOLUTION