Hello,
I have been using the script below for some time now and so far I thought the script was good..
Yesterday, however I had to type and email address that ended with co.uk and the script couldn't come out of the email validation loop..
Could someone please help me to find a way around it?
I seen example using regular expression but I am struggling in understanding it it work/learning it.
I have been using the script below for some time now and so far I thought the script was good..
Yesterday, however I had to type and email address that ended with co.uk and the script couldn't come out of the email validation loop..
Could someone please help me to find a way around it?
I seen example using regular expression but I am struggling in understanding it it work/learning it.
Code:
#!/bin/sh
#
# Set email varialble
email=""
confirm_email=""
while true; do
read -p "Enter wp admin email : " email
read -p "Comfirm email : " confirm_email
## Do they match?
if [ "$email" != "$confirm_email" ]; then
echo "These email addresses don't match. Try again?"
continue;
fi
## Is it a valid email address?
echo "$email" | grep '^[a-zA-Z0-9]*@[a-zA-Z0-9]*\.[a-zA-Z0-9]*$' >/dev/null 2>&1
if [ $? -ne 0 ]; then
echo "Email address isn't valid. Try again?"
continue;
fi
break;
done