initial commit
This commit is contained in:
29
chapter10/function_test_string
Executable file
29
chapter10/function_test_string
Executable file
@@ -0,0 +1,29 @@
|
||||
test_string ()
|
||||
{
|
||||
if (( $# != 1 ))
|
||||
then
|
||||
echo 'ERROR'
|
||||
return
|
||||
fi
|
||||
|
||||
C_STRING=$1
|
||||
|
||||
# Test the character string for its composition
|
||||
|
||||
case $C_STRING in
|
||||
|
||||
+([0-9])) echo 'POS_INT' # Integer >= 0
|
||||
;;
|
||||
+([-0-9])) echo 'NEG_INT' # Integer < 0
|
||||
;;
|
||||
+([a-z])) echo 'LOW_CASE' # lower case text
|
||||
;;
|
||||
+([A-Z])) echo 'UP_CASE' # UPPER case text
|
||||
;;
|
||||
+([a-z]|[A-Z])) echo 'MIX_CASE' # MIxed CAse text
|
||||
;;
|
||||
*) echo 'UNKNOWN' # Anything else
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user