The below code snippet shows how to use for loop in shell script .
List="one two three"
for a in $List # Splits the variable in parts at whitespace.
do
echo "$a"
done
# one
# two
# three
echo "---"
for a in "$List" # Preserves whitespace in a single variable.
do # ^ ^
echo "$a"
done
# one two three
echo "---"
for file in `ls * 2>/dev/null`
do
echo "File name : $file"
done
OUTPUT :
-bash-3.2$ sh for-loop-ex
one
two
three
---
one two three
---
File name : arithmatic_sh
File name : case_example
File name : check_min_params
File name : comparion_op_ex
File name : for-loop-ex
File name : passing_parameter_mech
File name : simple_function
File name : simple_multiplication
Explanation :
ls * 2>/dev/null
it will try to list all the files in current directory if there is no files found in current directory means it surpress the warning message
/dev/null this is the 0 device file
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