The below code snippet shows how can we use case statement in shell script. case is acting here like switch statement in programming languages.
-bash-3.2$ cat case_example
#!/bin/bash
# Testing ranges of characters.
echo; echo "Hit a key, then hit return."
read Keypress
case "$Keypress" in
[[:lower:]] ) echo "Lowercase letter";;
[[:upper:]] ) echo "Uppercase letter";;
[0-9] ) echo "Digit";;
* ) echo "Punctuation, whitespace, or other";;
esac # Allows ranges of characters in [square brackets],
exit 0
-bash-3.2$
OUTPUT:
-bash-3.2$ sh case_example
Hit a key, then hit return.
a
Lowercase letter
-bash-3.2$ sh case_example
Hit a key, then hit return.
B
Uppercase letter
-bash-3.2$ sh case_example
Hit a key, then hit return.
4
Digit
-bash-3.2$ sh case_example
Hit a key, then hit return.
!
Punctuation, whitespace, or other
Explanation :
read Keypress --> used to get input from keyboard
[[:lower:]] --> it accept all lower case characters
[[:upper:]] --> it accept all upper case characters
[0-9] --> it accepts all digits
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