The below code snippet shows how to pass the parameters to the function in shell script. If we used $1,$2,,,$n with in the function
$1 says first argument of this function
$2 says second argument of this function
.
.
.
$n says nTh argument of this function.
#!/bin/bash
add()
{
x=$1;
y=$2;
z=`expr $x + $y`;
echo $z
}
sum=`add 10 20`
echo "sum x=10 y=20 x+y=$sum"
OUTPUT:
-bash-3.2$ sh passing_parameter_mech
sum x=10 y=20 x+y=30
sum=`add 10 20`
calling the function add with passed two parameters 10 and 20 and return value is assigned into variable sum here need to put it both side of function call `(tilde) sign.
x=$1
values of 10 is assigned into the variable x
y=$2
values of 20 is assigned into the variable y
we can call x and y as dereferenced variables in shell function.
A Language is not worth knowing unless it teaches you to think differently.
Subscribe to:
Post Comments (Atom)
Price List Query for Item
SELECT qph.list_header_id, qph.name, qph.description, qphh.start_date_active, qphh.currency_code, q...
-
1. To download Ldt file for a Concurent Program FNDLOAD [username]/[password] O Y DOWNLOAD $FND_TOP/patch/115/import/afcpprog.lct file_nam...
-
Here the article will describe about how to register WebADI to Responsibility menu Go to System Administrator --> Security --> Respo...
-
using the below query can check the invoice status. SELECT DECODE(AP_INVOICES_UTILITY_PKG.GET_APPROVAL_STATUS(AIA.INVOICE_...
No comments:
Post a Comment