Cloudkul Support

How to verify an e-mail address in bash script ?

To verify an e-mail address, we take help of regular expressions in bash script.

script is as follows:

#!/bin/bash

regex="^(([-a-zA-Z0-9\!#\$%\&\'*+/=?^_\`{\|}~]+|(\"([][,:;<>\&@a-zA-Z0-9\!#\$%\&\'*+/=?^_\`{\|}~-]|(\\\\[\\ \"]))+\"))\.)*([-a-zA-Z0-9\!#\$%\&\'*+/=?^_\`{\|}~]+|(\"([][,:;<>\&@a-zA-Z0-9\!#\$%\&\'*+/=?^_\`{\|}~-]|(\\\\[\\ \"]))+\"))@\w((-|\w)*\w)*\.(\w((-|\w)*\w)*\.)*\w{2,4}$"
echo "ENTER THE E-MAIL ADDRESS"
read i

if [[ $i =~ $regex ]] ; then
    echo "OK"
else
    echo "not OK"
fi

Now run the script and type the e-mail address u want to check.

Is this article is helpful?

People like and 0 people dislike.

If result is not found or irrelevant, Please contact us.

Submit your request

Start a Project




    Message Sent!

    If you have more details or questions, you can reply to the received confirmation email.

    Back to Home