• 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: Multiline awk needs debugging
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Multiline awk needs debugging


  • Subject: Re: Multiline awk needs debugging
  • From: Chap Harrison <email@hidden>
  • Date: Mon, 26 Jan 2004 11:45:49 -0600

I hacked for a while to get your inline version working, then punted and created the awk script as a separate file. I think your original solution has problems both with Mac vs. Unix line endings and with awk statements not ending with semicolons. (The awk docs imply that these are optional, but at some point in the past I decided it was better to just always put them there).

Take the following and paste it into a new, plaintext TextEdit doc. Save it (for example, on the Desktop as foo.awk).

### begin awk script
NR==1 {
print "<tr>";
next;
}

function p(name) {
print "<td class=" name ">" saved[name];
saved[name]="";
}

/^<tr>/ {
p("Name");
p("Album");
p("Genre");
p("Size");
p("Year");
p("Comments");
print "<tr>";
next;
}

{
key=$1;
gsub(/.*=/,"",key);
saved[key]=$2;
}
### end awk script

I then changed your 'do shell script' command to read

set awkFile to ((path to (desktop folder) from user domain) & "foo.awk") as string
set awkPOSIX to the quoted form of the POSIX path of awkFile
:
do shell script "awk -F'>' -f " & awkPOSIX & " " & flipPOSIX & ">" & flopPOSIX

That seems to work for me. There may be a way to put the awk script inline in your applescript, as you tried, but I don't know what it is.

Chap
_______________________________________________
applescript-users mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/applescript-users
Do not post admin requests to the list. They will be ignored.

  • Follow-Ups:
    • Re: Multiline awk needs debugging
      • From: Gnarlodious <email@hidden>
References: 
 >Multiline awk needs debugging (From: Gnarlodious <email@hidden>)

  • Prev by Date: Re: Styled text in Panther
  • Next by Date: Re: applescript and browsers
  • Previous by thread: Multiline awk needs debugging
  • Next by thread: Re: Multiline awk needs debugging
  • Index(es):
    • Date
    • Thread