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 #10290 of 10298 |
Re: [ce-gnu-lug] Bash Script Help

Maybe awk isn't really getting considered anymore? :)

awk '/start_pattern/,/stop_pattern/' file.txt

For example..

awk '/Battery/,/^$/' file.txt

Will show me everything following the battery block up to the next block of text.

Well.. maybe someone will find that useful.


Best regards,


John Clark

On Thu, Jan 26, 2012 at 7:11 PM, joseph blase <josifire@...> wrote:
 

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


From: Noel Martin Llevares <noelmartin@...>
To: ce-gnu-lug@yahoogroups.com
Sent: Thursday, January 26, 2012 3:31 PM
Subject: Re: [ce-gnu-lug] Bash Script Help

 
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@...> 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@...> 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
To Unsubscribe, send a blank message to: ce-gnu-lug-unsubscribe@yahoogroups.com

Visit our website at: http://www.cegnulug.orgYahoo! Groups Links

<*> To visit your group on the web, go to:
   http://groups.yahoo.com/group/ce-gnu-lug/

<*> Your email settings:
   Individual Email | Traditional

<*> To change settings online go to:
   http://groups.yahoo.com/group/ce-gnu-lug/join
   (Yahoo! ID required)

<*> To change settings via email:
   ce-gnu-lug-digest@yahoogroups.com
   ce-gnu-lug-fullfeatured@yahoogroups.com

<*> To unsubscribe from this group, send an email to:
   ce-gnu-lug-unsubscribe@yahoogroups.com

<*> Your use of Yahoo! Groups is subject to:
   http://docs.yahoo.com/info/terms/







Thu Jan 26, 2012 11:38 am

njclark
Offline Offline
Send Email Send Email

Message #10290 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 Offline 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 Offline 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