Search the web
Sign In
New User? Sign Up
ce-gnu-lug · Cebu GNU/Linux Users Group

Group Information

  • Members: 241
  • Category: Linux
  • Founded: Dec 2, 1999
  • Language: English
? Already a member? Sign in to Yahoo!

Yahoo! Groups Tips

Did you know...
Hear how Yahoo! Groups has changed the lives of others. Take me there.

Messages

  Messages Help
Advanced
Bash Script Help   Message List  
Reply Message #10287 of 10298 |
Re: [ce-gnu-lug] Bash Script Help

Hi Noel,

What exact data are you trying to extract? Are you trying to extract
the name and e-mail address? If so, then maybe you can try this:

echo 'From: "Noel Martin Llevares" <noelmartin@...>' | sed
's/From: "\?\([^"]*\)"\? <.*/\1/'

and

echo 'From: Noel Martin Llevares <noelmartin@...>' | sed 's/From:
"\?\([^"]*\)"\? <.*/\1/'


[ simon.cpu ]

On Thursday, 26 January, 2012 03:31 PM, Noel Martin Llevares wrote:
>
>
> Actually making a script to parse *.eml files and extract the From: and
> To: headers but it turns out some email headers have their names
> enclosed in quotes like "Noel Martin Llevares" <noelmartin@...
> <mailto:noelmartin@...>> but some doesn't have. I'm having a hard
> time making a generalized parser.
>
> Right now, I'm thinking at looking for Python or Perl modules that can
> do that. I'm looking at http://www.chilkatsoft.com/python.asp right now.
>
> Noel
>
> On Thu, Jan 26, 2012 at 3:19 PM, Simon Cornelius P. Umacob
> <soulfury@... <mailto:soulfury@...>> wrote:
>
> Hi Noel,
>
> What exactly are you trying to do?
>
> [ simon.cpu ]
>
> On Thursday, 26 January, 2012 03:12 PM, Noel Martin Llevares wrote:
> >
> >
> > Hi everyone,
> >
> > I have been trying to google this specific problem for hours
> already but
> > I still can't get this right. It's about string processing in the
> linux
> > terminal using grep, sed, awk, bash, etc.
> >
> > The string in question is like this:
> >
> > The "quick brown" fox
> >
> > jumped over
> >
> >
> > The 2nd and 3rd words in the first line are enclosed in quotes.
> But for
> > some lines there are only two words. I need to read each line and
> parse
> > the 2 or 3 words so that I can use them as parameters for awk.
> >
> > I wanted the results for the first line to be like $1=The, $2="quick
> > brown", and $3=fox. But for the second line, $1=jumped, $2=,
> $3=over. If
> > the phrase in quotes is missing, $2 should be blank.
> >
> > I would appreciate if someone could point me to some pointers. I have
> > been grappling with grep, sed and awk for hours now and I still
> couldn't
> > get it.
> >
> > Any help would be appreciated. Thanks.
> >
> > Noel
> >
>
>
>
> ------------------------------------
>
> To Post a message, send it to: ce-gnu-lug@yahoogroups.com
> <mailto:ce-gnu-lug@yahoogroups.com>
> To Unsubscribe, send a blank message to:
> ce-gnu-lug-unsubscribe@yahoogroups.com
> <mailto:ce-gnu-lug-unsubscribe@yahoogroups.com>
>
> Visit our website at: http://www.cegnulug.orgYahoo! Groups Links
>
>
> ce-gnu-lug-fullfeatured@yahoogroups.com
> <mailto:ce-gnu-lug-fullfeatured@yahoogroups.com>
>
>
>
>




Thu Jan 26, 2012 8:07 am

simoncpu_ph
Offline Offline
Send Email Send Email

Message #10287 of 10298 |
Expand Messages Author Sort by Date

Hi everyone, I have been trying to google this specific problem for hours already but I still can't get this right. It's about string processing in the linux ...
Noel Martin Llevares
nml_21 Offline Send Email
Jan 26, 2012
7:13 am

Hi Noel, What exactly are you trying to do? [ simon.cpu ]...
Simon Cornelius P. Um...
simoncpu_ph Offline Send Email
Jan 26, 2012
7:19 am

Actually making a script to parse *.eml files and extract the From: and To: headers but it turns out some email headers have their names enclosed in quotes...
Noel Martin Llevares
nml_21 Offline Send Email
Jan 26, 2012
7:31 am

Hi Noel, What exact data are you trying to extract? Are you trying to extract the name and e-mail address? If so, then maybe you can try this: echo 'From:...
Simon Cornelius P. Um...
simoncpu_ph Offline Send Email
Jan 26, 2012
8:08 am

parsing email headers is a complex beast. If you know how some Perl, you can try this http://search.cpan.org/~rjbs/Email-Folder-0.855/lib/Email/Folder.pm ...
joseph blase
josifire Online Now Send Email
Jan 26, 2012
11:11 am

Maybe awk isn't really getting considered anymore? :) awk '/start_pattern/,/stop_pattern/' file.txt For example.. awk '/Battery/,/^$/' file.txt Will show me...
John Clark Naldoza
njclark Online Now Send Email
Jan 26, 2012
11:38 am

I wanted to get those From: and To: headers parsed so I can use awk to produce a tab-delimited file with the data. I found a Ruby gem that can parse emls, I'm...
Noel Martin Llevares
nml_21 Offline Send Email
Jan 26, 2012
9:50 pm
Advanced

Copyright © 2010 Yahoo! Inc. All rights reserved.
Privacy Policy - Terms of Service - Guidelines NEW - Help