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)
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