Looking for regex to extract email addresses from /etc/passwd
Posted
by Brent
on Stack Overflow
See other posts from Stack Overflow
or by Brent
Published on 2008-09-18T18:26:26Z
Indexed on
2010/03/19
4:31 UTC
Read the original article
Hit count: 327
Most of my users have email addresses associated with their profile in /etc/passwd. They are always in the 5th field, which I can grab, but they appear at different places within a comma-separated list in the 5th field.
Can somebody give me a regex to grab just the email address (delimeted by commas) from a line in this file? (I will be using grep and sed from a bash script)
Sample lines from file:
user1:x:1147:5005:User One,Department,,,[email protected]:/home/directory:/bin/bash
user2:x:1148:5002:User Two,Department2,[email protected],:/home/directory:/bin/bash
© Stack Overflow or respective owner