# EMail Address Validation (Shell Script)

**URL:** <https://community.unix.com/t/email-address-validation-shell-script/240552>\
**Category:** Shell Programming and Scripting\
**Created:** [May 20, 2009, 9:47am UTC](https://community.unix.com/t/email-address-validation-shell-script/240552 "2009-05-20T09:47:56Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![balajiora](https://community.unix.com/letter_avatar/balajiora/32/6_449c533f586939b6e5f246632a46421f.png) [@balajiora](https://community.unix.com/u/balajiora)\
**Post date:** [May 20, 2009, 9:47am UTC](https://community.unix.com/t/email-address-validation-shell-script/240552/1 "2009-05-20T09:47:56Z")

</div>

Hi,

Can anyone provide me the code snippet for EMail Address Validation.

User is going to enter the email address in form window. I need to validate the format is correct.

Thanks in Advance

BS

---

<div class="post-metadata">

**Author:** ![cfajohnson](https://community.unix.com/user_avatar/community.unix.com/cfajohnson/32/16669_2.png) [@cfajohnson](https://community.unix.com/u/cfajohnson)\
**Post date:** [May 20, 2009, 1:17pm UTC](https://community.unix.com/t/email-address-validation-shell-script/240552/2 "2009-05-20T13:17:13Z")

</div>

```nohighlight
case $1 in
 *@?*.?*) echo valid ;;
  *) echo not valid; false ;;
esac

```

---

<div class="post-metadata">

**Author:** ![balajiora](https://community.unix.com/letter_avatar/balajiora/32/6_449c533f586939b6e5f246632a46421f.png) [@balajiora](https://community.unix.com/u/balajiora)\
**Post date:** [May 20, 2009, 2:49pm UTC](https://community.unix.com/t/email-address-validation-shell-script/240552/3 "2009-05-20T14:49:40Z")

</div>

I really appreciate your immediate reply. Code snippet what you have provided is returning "valid" for wrong email id. Example [ab,cd@test.com](mailto:ab,cd@test.com)

Could you please help me to resolve this issue.

Regards  
BS

---

<div class="post-metadata">

**Author:** ![vgersh99](https://community.unix.com/user_avatar/community.unix.com/vgersh99/32/14851_2.png) [@vgersh99](https://community.unix.com/u/vgersh99)\
**Post date:** [May 20, 2009, 3:41pm UTC](https://community.unix.com/t/email-address-validation-shell-script/240552/4 "2009-05-20T15:41:51Z")

</div>

Here's one discussion thread on the [email address](http://groups.google.com/group/comp.lang.awk/browse_thread/thread/31e46325833585c4/16052fa90887fe48?lnk=gst&q=email%2Baddress#16052fa90887fe48) subject.  
This is NOT a complete solution as one would have to implement the [RFC 821](http://www.faqs.org/rfcs/rfc821.html), [RFC 822](http://www.faqs.org/rfcs/rfc822.html), [RFC 733](http://www.faqs.org/rfcs/rfc733.html).  
Use Google to find other sources.
