• 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: "Mark J. Reed" <email@hidden>
  • Date: Fri, 15 Dec 2006 10:19:13 -0500

On 12/15/06, Martin Orpen <email@hidden> wrote:
Oh, I thought John had already handled the easier awk stuff and it
was the field separators that were problematic?


awk 'BEGIN { OFS="\n" } { print $1, $NF-2, $NF-1, $NF }'

-->
17
2003
2004
2005-10-7,13:45:34.0

You still don't seem to understand the scope of the problem. And since I know how smart you are, I'm confused by that. :) Am I missing something?

The goal is to write something that, given this line as input:

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

will produce as output a list of five fields,where the first field is
"17", the second is "Security Update for Exchange 2000 Server
(KB894549)", the third is "zeroDotZero", the fourth is "application",
and the fifth is "2005-10-7,13:45;34.0".

Awk's default column-split behavior won't do that.  And if it could,
it wouldn't be needed, because you could do it in AppleScript with
text item delimiters.

There are various ways to code a solution to this problem, but the
simplest seems to me to be to use a regex that matches both quoted and
unquoted fields.  So that's what I did.  Although my solution doesn't
provide for quotation marks within quoted strings.

--
Mark J. Reed <email@hidden>
_______________________________________________
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
  • Follow-Ups:
    • Re: awk question
      • From: Martin Orpen <email@hidden>
    • Re: awk question
      • From: Martin Orpen <email@hidden>
    • Re: awk question
      • From: "John C. Welch" <email@hidden>
References: 
 >Re: awk question (From: "John C. Welch" <email@hidden>)
 >Re: awk question (From: Martin Orpen <email@hidden>)
 >Re: awk question (From: email@hidden)
 >Re: awk question (From: Martin Orpen <email@hidden>)

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