I've got the basics of bash scripting (I think anyways), and i'm trying to move on to more advanced stuff.
I am trying to write a script that will perform input validation (the user must input either yes or no) and i'm trying to do this by combining a function and an if then else statement.
This is what i'm working on so far.
#!/bin/bash
func ()
{
echo "Enter yes or no:"
read var1
}
if [ $var1 != yes ] || [ $var1 != no ]
then
func
else
echo "I'm glag you said $var1"
fi
exit 0
I know that i'm using the wrong if then else operator/syntax, but I can't find the correct syntax threw googling.
I want it to run the function if var1 is either equal to yes or no, so the user can't input something else.
ifand notwhileto insist until the input is correct? – manatwork Mar 02 '14 at 17:20