• 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: Q: echo | sed -- Solved!
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Q: echo | sed -- Solved!


  • Subject: Re: Q: echo | sed -- Solved!
  • From: Gnarlodious <email@hidden>
  • Date: Tue, 18 May 2004 12:57:02 -0600

Aargh! This \n vs \r line ending thing gives me a headache!
How I wish Apple had done away with \r when adopting Unix.

I don't have Script Editor here, but now we know why it doesn't work in SD.


Entity Nigel Smith spoke thus:

> On your replaceLines, using Mac delimiters you are echoing a single line
> into sed, which replaces the 2 with the 8, spits it back out as a single
> line, which your editor then displays as multiple lines because of the Mac
> line breaks.
>
You are absolutely right, that explains it.
Here's the proof:

set someLines to "2
2
2
2
2
2"

do shell script "echo " & someLines & " | sed 's/2/8/'" -- first instance

-- > 8\r2\r2\r2\r2\r2


do shell script "echo " & someLines & " | sed 's/2/8/g'" -- all instances

-- > 8\r8\r8\r8\r8\r8


So Unix only operates on one line, while Mac sees multiple lines (whew).

> Different behaviour in the different editors is down to them using different
> line endings when you hit "return" in mid-string.

Evidently Script Editor and Smile convert the \r characters to \n along with
"quoted form of" but Script Debugger does not. I've reported it as a bug.

Thanks for the insight.

-- Gnarlie
Currently broadcasting from
N35:40:06/W105:57:51
_______________________________________________
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: Q: echo | sed -- Solved!
      • From: Christopher Nebel <email@hidden>
    • Re: Q: echo | sed -- Solved!
      • From: Paul Berkowitz <email@hidden>
References: 
 >Re: Q: echo | sed -- Solved! (From: Nigel Smith <email@hidden>)

  • Prev by Date: FW: Q: echo | sed ; can't replace range of lines
  • Next by Date: Finding the oldest date in a list
  • Previous by thread: Re: Q: echo | sed -- Solved!
  • Next by thread: Re: Q: echo | sed -- Solved!
  • Index(es):
    • Date
    • Thread