Re: Q: echo | sed -- Solved!
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.