• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: awk question
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: awk question


  • Subject: Re: awk question
  • From: Luca Pozzato <email@hidden>
  • Date: Fri, 1 Dec 2006 19:59:54 +0100

Hi John,
I don’t know AWK, but this is I would do it in Applescript (with Satimage Osax)…

set x to "17    \"Security Update for Exchange 2000 Server (KB894549)\"     zeroDotZero       application  2005-10-7,13:45:34.0"

set k to every paragraph of (change {"[[:space:]][[:space:]]+"} in x into {"\\r"} with regexp)



Luca



On 01/dic/06, at 19:08, John C. Welch wrote:

I'm running into a situation that I've not found a good example for via Google or other sources.

running a script that's designed to process some SNMP output. Awk is a good choice here, and it's being run via do shell script, but I have a twist that's giving me the irrits.

each line has two field delimiters. The most common one is a space. that's easy. The problem is in what I want to be column two, there’s a text string surrounded by double quotes that contains spaces. As an example:

17    "Security Update for Exchange 2000 Server (KB894549)"     zeroDotZero       application  2005-10-7,13:45:34.0

so I’m trying to get awk to run as “your field delimiters are spaces OR double quotes with any number of any characters or whitespace followed by double quotes”

I can get close, but not close enough to what I want which would be:

$1 = 17    
$2 = "Security Update for Exchange 2000 Server (KB894549)"     
$3 =  zeroDotZero       
$4 = application  
$5 = 2005-10-7,13:45:34.0

ideas?

 _______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/mailman//archives/applescript-users

This email sent to email@hidden

References: 
 >awk question (From: "John C. Welch" <email@hidden>)

  • Prev by Date: awk question
  • Next by Date: Re: awk question
  • Previous by thread: awk question
  • Next by thread: Re: awk question
  • Index(es):
    • Date
    • Thread