Results 1 to 8 of 8
Enjoy an ad free experience by logging in. Not a member yet? Register.
i need some help using grep in a fairly advanced way...
basically throughout the file, there exists instances of (firstname.lastname@example.org)
along with ALOT of other garbage i dont need....
i just want to produce an output file containing nothing but one email on each line.... but getting all the emails out of the file WITHOUT getting the emails that are NOT in ()
maybe something like:
grep -w '(.*)' file??? OR
grep -w '.com\|.@.' file???
PLEASE help ... and btw how do you change a file type from data to ASCII??
12-02-2005 #2but getting all the emails out of the file WITHOUT getting the emails that are NOT in ()
Let's take an example file called some-file. It contains:Code:
encryptedstuff2349823423 email@example.com (firstname.lastname@example.org) encryptedstuff293843 encryptedstuff3297983283 email@example.com (firstname.lastname@example.org) encryptedstuff984372Code:
grep -o '(.*@domain.com)' some-file
Don't want parens in the output? Then use:Code:
grep -o '(.*@domain.com)' some-file | tr -d '()'
but what if the domain varies with EACH email (and there are like 1000+)???Code:
grep -o '(.*@.*.com)' some-file???
P.S. If the email does not always have the same domain you could probably use something likeCode:
grep -o '(.*@.*\.com)' some-file | tr -d '()'
ok i think i am beginning to understand grep a little better now
.*@.*\.com = the \.com tells grep the next anticipated occurence should be
at the beginning of the NEXT expression???
The \.com means: Escape the . and treat it literally. And treat com literally.
Here is one more example for you:Code:
dpecs@lnxvm3:~> grep -o '(.*@.*\..*)' some-file | tr -d '()'
Here is a short tutorial on regular expressions if you're interested: http://forums.suselinuxsupport.de/in...howtopic=23485
thank you very much again
btw i was thinking of grep -w '\<bay' *
that one does any word in any line that begins with bay....
sorry i am very new to grep (its very powerful and i like it)