The below code snippet shows how can we declare global and local variables in shell scripts.
#!/bin/bash
x=10
increment()
{
echo "global variable : before increment value x=$x"
(( x++ ))
}
increment
echo -e "global variable : after increment value x=$x\n"
localVar()
{
local var_local=50;
echo "inside localVar function value of var_local = $var_local"
}
localVar
echo "inside localVar function value of var_local = $var_local"
OUTPUT :
-bash-3.2$ sh local_global_var_ex
global variable : before increment value x=10
global variable : after increment value x=11
inside localVar function value of var_local = 50
inside localVar function value of var_local =
global variable is declared outside the function
local variable is delcared in side the function with key word local.
we cant use local variable outside the function but global variable can use inside/outside the 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