Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

I need some help validating

Status
Not open for further replies.

Flipster

MIS
Jun 25, 2001
38
0
0
US
I need some help validating a user entered string. I know this is basic programming stuff...but...

I am asking for a user to input an "e" or an "f"

How do I kick out of the script if it is neither?

There must be a way to do

if $I != [e,f]
then
echo " I said e or f!!!"
quit
fi



Thanks for the help.
 
#!/bin/ksh

a='fa'

if [[ "${a}" != @(e|f) ]] ; then
echo "[$a] NOT [e,f]"
else
echo "[$a] IS [e,f]"
fi;
vlad
+---------------------------+
|#include<disclaimer.h> |
+---------------------------+
 
Simplest is case IMO:
a=0
while test $a -eq 0
do
echo -n &quot;$Optionstring&quot;
read ans
case $ans in

e|E) echo &quot;Valid&quot;;;
f|F) echo &quot;Valid&quot;;;
*) echo &quot;Non valid.&quot; ; a=1 ;;
esac
done
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top