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)
Item - Category Query
SELECT msi.segment1 AS Item_Code, msi.DESCRIPTION AS Item_Desc, mcs.CATEGORY_SET_NAME, mck.CONCATENATED_SEGMEN...
-
1. To download Ldt file for a Concurent Program FNDLOAD [username]/[password] O Y DOWNLOAD $FND_TOP/patch/115/import/afcpprog.lct file_nam...
-
The profile information available in the HZ_CUSTOMER_PROFILES can be created in three levels namely Party, Customer Account and Customer...
-
Here the article will describe about how to register WebADI to Responsibility menu Go to System Administrator --> Security --> Respo...
No comments:
Post a Comment