noqqe » blog | sammelsurium | photos | projects | about

Bash Email Validation

2011-06-07 @ Programming, RegEx

Validieren von Email in Bash

regex="^[a-z0-9!#\$%&'*+/=?^_\`{|}~-]+(\.[a-z0-9!#$%&'*+/=?^_\`{|}~-]+)*@([a-z0-9]([a-z0-9-]*[a-z0-9])?\.)+[a-z0-9]([a-z0-9-]*[a-z0-9])?\$"

i="test@terra.es"
if [[ $i =~ $regex ]] ; then
   echo "OK"
else
   echo "not OK"
fi