Header Ads

Shell Scripting : Example of a Simple Function for Addition - 10

This is a simple Shell script for Adding 2 Numbers' by calling Function.

Program Code:

#!/bin/bash
#Function definition

function sum()
{
 x=`expr $1 + $2`
 echo " $x"
}
 
#Calling the function
sum 5 3
echo " The sum of 4 and 7 is : `sum 4 7`"

Program Output:

No comments