• 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: sed: escaping UNIX newlines
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: sed: escaping UNIX newlines


  • Subject: Re: sed: escaping UNIX newlines
  • From: BJ Terry <email@hidden>
  • Date: Sun, 18 Jan 2004 17:48:49 -0800

There's still some stuff later on in the script that's going weird, but
I changed these two parts:


--do shell script "tr -d '
--' " & "<" & inPOSIX & ">" & flipPOSIX -- remove Mac line returns
do shell script "cat " & inPOSIX & " > " & flipPOSIX


do shell script "sed -e 's|<tr>|\\
<tr>|g' " & ,
flopPOSIX & ">" & flipPOSIX -- every row is a line of cells

For the first fragment, the commented portion removes the line endings,
which makes your sed command work incorrectly, as far as I can tell.
You can change your sed command instead, but changing this part was
easier. Basically, sed operates only on lines, and the files didn't
have lines anymore.

For the second fragment: sed doesn't support \n as newline, \n is taken
as a literal "n" instead. You have to escape an actual newline
character to put a newline in the replacement string.

It's not everything, but it's closer. Doing this gets every <tr> on
it's own line, followed by a bunch of <td>s

BJ


On Jan 18, 2004, at 4:03 PM, Gnarlodious wrote:

> First off I want to thank those who helped me on this script, Chris
> Janton,
> BJ Terry and Michael Terry for excellent pointers.
> I've learned a lot, here is the script so far:
> <http://www.Gnarlodious.com/OSX/AppleScript/iTunes-iPage.scpt.html>
>
> If you copy and paste this script to run it erase the international
> character block as the export to HTML mangles them.
>
> The problem is that I need to make onelines out of all cells to use
> the sort
> command, for example any newline followed by <td> needs to be changed
> to
> only <td>. This leaves a newline before the <tr> so sort can work its
> magic
> and cw can count lines.
>
> As you can see I eradicated all newlines with tr and attempted to
> reinsert
> them with sed but I don't know if I'm doing it right. Is it an
> Applescript
> issue or can't sed do this?
>
> -- Gnarlie
> _______________________________________________
> 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.

[demime 0.98b removed an attachment of type application/pkcs7-signature which had a name of smime.p7s]
_______________________________________________
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: sed: escaping UNIX newlines
      • From: Gnarlodious <email@hidden>
References: 
 >sed: escaping UNIX newlines (From: Gnarlodious <email@hidden>)

  • Prev by Date: sed: escaping UNIX newlines
  • Next by Date: Re: sed: escaping UNIX newlines
  • Previous by thread: sed: escaping UNIX newlines
  • Next by thread: Re: sed: escaping UNIX newlines
  • Index(es):
    • Date
    • Thread