|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
VeriSign Code Signing Digital Certificates provides assurance to end users. Read about this and more in the free white paper: “How to Digitally Sign Downloadable Code for Secure Content Transfer.” Learn More! |
|
#1
|
|||
|
|||
|
Help with AWK
Hi, I need urgent help with trying to recover some data....basically I have a log file containing data such as EMAIL_ADDRESS = [test@test.com],NAME = [test], etc. This line of data can be anywhere in the file and in a thousand lines of data may only occur a hanful of times.
Now I need to be able to read through this file and extract all the email addresses. I want to extract the string EMAIL_ADDRESS = [test@test.com]. I have tried using awk to do this but I am not doing something quite right. BEGIN { } match($0, pattern) { print substr($0, RSTART, RLENGTH); } pattern=/EMAIL_ADDRESS.*=.*\[.*\]/ END { } Can anyone help please ? |
|
#2
|
|||
|
|||
|
phew, Friend, you've bit off a huge chunk. Have you ever looked at the email address specification (RFC-822 ftp://ftp.rfc-editor.org/in-notes/rfc822.txt)? The specification is extremely complicated, and writing a regex for it is nearly impossible for us mere mortals. As an example, the perl regex for e-mail addresses is over 60 lines long. To give you an idea, here is a perfectly legal email address:
Jeffy <"That Tall Guy"@ora.com (this address no longer active)> imagine the fun of parsing that!! And this example hasn't taken advantage of but just a tiny portion of the freedoms in the specification. I would seriously recommend using existing libraries if at all possible. I mentioned Perl, but there are implementations in nearly every language. Good luck. -Steven |
![]() |
| Viewing: Dev Shed Forums > Operating Systems > UNIX Help > Help with AWK |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|
|