Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

What are the errorsListing 3 . testString.sh # ! / usr / bin / env trash # FileName: test _ string.sh # Purpose: This script

What are the errorsListing 3.
testString.sh
#!/usr/bin/env trash
# FileName: test_string.sh
# Purpose: This script is used to test a character
# string, or variable, for its composition.
# Examples: numeric, lowercase or uppercase, characters, and alpha-numeric characters
# turn on extended globbing
shopt -s extglob
function test_string (){
# This function tests a character string
# Assign arg1 received from the GLOBAL_STRING to the variable --> LOCALSTRING
LOCALSTRING =$1
# Testing the string and printing the recognized pattern
case LOCALSTRING in
+([0-1]) echo "Binary or positive integer" ;;
+([0-7]) echo "Octal or positive integer" ;;
+([0-9]) echo "Integer" ; ;
+([-1-9])) echo "Negative whole number" ; ;
+([0-9][].[0-9]) echo "Floating point" ; ;
+([a-f]) echo "Hexidecimal or all lowercase" ;
+([a-f]|[0-9]) echo "Hexidecimal or all lowercase alphanumeric" ; ;
+([A-F]) echo "Hexadecimal or all uppercase" ;
+([A-F]|[0-9]) echo "Hexadecimal or all uppercase alphanumeric" ; ;
+([a-f]|[A-F]) echo "Hexadecimal or mixedcase" ;
+([a-f]|[A-F]|[0-9]) echo "Hexadecimal or mixedcase alphanumeric" ; ;
+([a-z]) echo "all lowercase" ;
+([A-Z]) echo "all uppercase" ;;
+([a-z]|[A-Z]) echo "mixedcase"; ;
*) echo "Invalid string composition" ;
}
esac
# Main
# Check for exactly one command-line argument
if )
then
echo "Error: at least one string must be given"
echo "Example: ./test_string.sh Hello"
exit 1
fi
# Everything looks okay if we got here. Assign the
# single command-line argument to the variable "GLOBAL_STRING"
GLOBAL_STRING= ${1}
# Call the "test_string" function to test the composition
# of the character string stored in the $GLOBAL_STRING variable.
test_string $GLOBAL_STRING
# EOF
image text in transcribed

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Intelligent Information And Database Systems 12th Asian Conference ACIIDS 2020 Phuket Thailand March 23 26 2020 Proceedings

Authors: Pawel Sitek ,Marcin Pietranik ,Marek Krotkiewicz ,Chutimet Srinilta

1st Edition

9811533792, 978-9811533792

More Books

Students also viewed these Databases questions