LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   grep question (https://www.linuxquestions.org/questions/programming-9/grep-question-168326/)

keyops 04-09-2004 07:49 PM

grep question
 
Hi

Trying to grep a 2 gig file for email addresses.

Have looked at using

grep ".*\@[^ ]*[a-zA-Z0-9\-]*\.[a-zA-Z0-9\-]*" <file>

but its not efficient. Can anyone help me on this? I also need to try and use sed or something to only display/copy out the email addresses themselves, not the junk either side. The file is basically a disk image, I used dd to dump it.

Its my old ntfs vol which freaked out big time and I am working in Linux...good learning exercise!

K

slakmagik 04-09-2004 08:32 PM

Depends on the format and I'm not sure what would count as efficient - or how precise you need to be. This
Code:

grep '.*@.*\..*' html/bookmarks.html | sed 's/^.*mailto://g;s/\".*$//g'
pulls email addresses out of a bookmarks file (not that most people have them there, but just for the idea).

Why did you dump an NTFS volume into a disk image with dd? Or do I not want to know? :)

strikeforce 04-09-2004 09:17 PM

create a sed statement searching for that string the most efficient I've seen is to actually use sed and grep together.


All times are GMT -5. The time now is 06:46 PM.