Is there any need to do this? How about grep? Here's how to use it with the regex that you specified:
$ cat dbdump.txt
db dump: someusername ::: kRW...0fPc ::: $2a$10$...aucvkDt86 ::: joesmith@gmail.com
another line with two e-mail addresses <test@example.com> on it -- bob@example.org
$ grep -EiEio '\b[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,4}\b' dbdump.txt
joesmith@gmail.com
test@example.com
bob@example.org
The flag -oprints only the relevant parts, i.e. email addresses only. -imakes a matching case insensitive. It even finds multiple email addresses on one line.
Edit: I could not resist -EiEio. I believe that grep -Eio, or egrep -iowill work too ...
source
share