Answered step by step
Verified Expert Solution
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
testString.sh
#usrbinenv trash
# FileName: teststring.sh
# Purpose: This script is used to test a character
# string, or variable, for its composition.
# Examples: numeric, lowercase or uppercase, characters, and alphanumeric characters
# turn on extended globbing
shopt s extglob
function teststring
# This function tests a character string
# Assign arg received from the GLOBALSTRING to the variable LOCALSTRING
LOCALSTRING $
# Testing the string and printing the recognized pattern
case LOCALSTRING in
echo "Binary or positive integer" ;;
echo "Octal or positive integer" ;;
echo "Integer" ; ;
echo "Negative whole number" ; ;
echo "Floating point" ; ;
echo "Hexidecimal or all lowercase" ;
echo "Hexidecimal or all lowercase alphanumeric" ; ;
echo "Hexadecimal or all uppercase" ;
echo "Hexadecimal or all uppercase alphanumeric" ; ;
echo "Hexadecimal or mixedcase" ;
echo "Hexadecimal or mixedcase alphanumeric" ; ;
echo "all lowercase" ;
echo "all uppercase" ;;
echo "mixedcase"; ;
echo "Invalid string composition" ;
esac
# Main
# Check for exactly one commandline argument
if
then
echo "Error: at least one string must be given"
echo "Example: teststring.sh Hello"
exit
fi
# Everything looks okay if we got here. Assign the
# single commandline argument to the variable "GLOBALSTRING"
GLOBALSTRING $
# Call the "teststring" function to test the composition
# of the character string stored in the $GLOBALSTRING variable.
teststring $GLOBALSTRING
# EOF
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started