The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com




View Single Post in the UNIX and Linux Forums - Click on the Thread or Permalink to View Entire Thread -->
  #2 (permalink)  
Old 12-03-2008
Christoph Spohr Christoph Spohr is offline
Registered User
  
 

Join Date: Sep 2008
Posts: 205
Hi,

i would try to extract the emails directly. For me this works with your sample:

Code:
email=($(grep -o "[0-9A-Za-z]\+@[0-9A-Za-z]\+\.[A-Za-z]\{2,3\}" file))
This writes all patterns, and only these patterns, matching the regexp
into the array email.

Code:
echo ${#email[0]}
Will give you the length of the first element. Without the "#" it will give
you the entry at position 0.

HTH Chris