• 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, 1 Dec 2006 17:31:59 -0500

Minor corrections - for some reason there were spurious quotes at the
end of my field[fnum] assignment line, and I neglected to remove the
quotation marks from quoted fields.  The below fixes those issues.

<datafile awk '{
   fnum = 1
   while (match($0,/"[^"]*"|[^   ][^     ]*/))
   {
       f = substr($0, RSTART, RLENGTH);
       if (substr(f,1,1) == "\"")
       {
           f = substr(f, 2, length(f) - 2)
       }
       field[fnum++] = f
       $0 = substr($0, RSTART + RLENGTH);
   }

   for (i=1; i<fnum; ++i)
   {
       print i": "field[i]
   }
}'

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

  • Prev by Date: Re: ctrl m question
  • Next by Date: Applescript to search filenames
  • Previous by thread: Re: awk question
  • Next by thread: Re: awk question
  • Index(es):
    • Date
    • Thread