• 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 replace oneline nogo in Applescript
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Sed replace oneline nogo in Applescript


  • Subject: Re: Sed replace oneline nogo in Applescript
  • From: Gnarlodious <email@hidden>
  • Date: Tue, 10 Feb 2004 08:00:34 -0700

Yes, BJ, your assumptions are correct.

It works when sent as a single command call, like what you did.
But when I concatenate the middle command it simply will not work:

do shell script "sed " & ,
"-e 's|<HR>|<BR>|' " & ,
"-e '2s|<H3>\\(.*\\)<\\/H3>|<h3><a href=\"\\.\\/\">\\1</a></h3>|' " & ,
"-e '1N;s|</A>\\(\\n<A\\)|</A> \\&#8226; \\1|;P;$!N;D' " & ,
flipPOSIX & ">" & flopPOSIX

Removing the "2" operates on all lines in the file.

I can't figure this out, maybe it's a buffering issue?

OTOH, the output string when pasted in Terminal doesn't work either, so that
excuses Applescript.

Thanks for the help.

-- Gnarlie

Entity BJ Terry spoke thus:

> What is it you're trying to accomplish? On my computer, I get identical
> results with a do shell script and entering it into the terminal. (When
> it's properly escaped, naturally). If I remove the 2, I get all lines
> substituted, if I add the two, I get only the second line in the file
> substituted:
>
> test.txt
> <H3>dog1</H3>
> <H3>dog2</H3>
> <H3>dog3</H3>
> <H3>dog4</H3>
>
> do shell script "sed -e '2s|<H3>\\(.*\\)<\\/H3>|<h3><a
> href=\"\\.\\/\">\\1</a></h3>|' ~/Desktop/test.txt"
>
> yields
>
> "<H3>dog1</H3>
> <h3><a href=\"./\">dog2</a></h3>
> <H3>dog3</H3>
> <H3>dog4</H3>"
>
> do shell script "sed -e 's|<H3>\\(.*\\)<\\/H3>|<h3><a
> href=\"\\.\\/\">\\1</a></h3>|' ~/Desktop/test.txt"
>
> yields
>
> "<h3><a href=\"./\">dog1</a></h3>
> <h3><a href=\"./\">dog2</a></h3>
> <h3><a href=\"./\">dog3</a></h3>
> <h3><a href=\"./\">dog4</a></h3>"
>
> Are these not the results for which you are searching?
>
> BJ
>
> On Feb 9, 2004, at 10:03 PM, Gnarlodious wrote:
>
>> The bugaboo is the "2" specifying the line number:
>>
>> sed -e '2s|<H3>\\(.*\\)<\\/H3>|<h3><a href=\"\\.\\/\">\\1</a></h3>|'
>>
>> Works in Terminal but not Applescript. If I remove the "2" it operates
>> on
>> all lines in the file.
>>
>> What am I doing wrong?
> _______________________________________________
> 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.
_______________________________________________
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 replace oneline nogo in Applescript
      • From: BJ Terry <email@hidden>
References: 
 >Re: Sed replace oneline nogo in Applescript (From: BJ Terry <email@hidden>)

  • Prev by Date: Photoshop to resize Illustrator eps's script
  • Next by Date: Re: Applescript Help!
  • Previous by thread: Re: Sed replace oneline nogo in Applescript
  • Next by thread: Re: Sed replace oneline nogo in Applescript
  • Index(es):
    • Date
    • Thread