vendredi 6 mars 2015

How to make an If-Then-Else statement that accepts only Capitals

I have a UNIX script written in korn shell. I need to make it so that this statement:



while true
do
echo "What is the last name of the person you would like to modify:"
read last_name
if line=$(grep -i "^${last_name}:" "$2")
then
IFS=: read c1 c2 c3 c4 rest <<< "$line"
echo -e "Last Name: $c1\nFirst Name: $c2\nState: $c4"
while true
do
echo "What would you like to change the state to?:"
read state
if [[ $state -eq [A-Z] ]];then
echo "State: $state"
echo "This is a valid input"
break
else
echo "Not a valid input:"
fi
done
else
echo "ERROR: $last_name is not in database"
echo "Would you like to search again (y/n):"
read delete_choice
case $delete_choice in [Nn]) break;; esac
fi
done
;;


Specifically, I am having trouble with this code:



if [[ $state -eq [A-Z] ]];then


The point of this program is to modify a record in a text file but will only take the input of state abbreviations such as (MI, WA, KS, ....).


Aucun commentaire:

Enregistrer un commentaire