Skip to content

Instantly share code, notes, and snippets.

@plainspooky
Created May 8, 2017 01:29
Show Gist options
  • Save plainspooky/bbf04e28819c09bac4279f042b01c758 to your computer and use it in GitHub Desktop.
Save plainspooky/bbf04e28819c09bac4279f042b01c758 to your computer and use it in GitHub Desktop.
#!/bin/bash
email_REGEX="[a-z0-9._%+-]+@[a-z0-9.-]+\.[a-z]{2,4}$"
email_to_check=${1}
if [ -z "${email_to_check}" ]; then
echo "É necessário inserir um endereço de e-mail!"
exit 2
else
if [[ "${email_to_check}" =~ ${email_REGEX} ]]; then
echo "O endereço '${email_to_check}' é válido!"
else
echo "O endereço '${email_to_check}' não é válido!"
exit 1
fi
fi
exit 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment