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>
>
>
>
>