sed and new-line on Solaris broken ?

sed and new-line on Solaris broken ?

Post by jmikl » Wed, 13 Jul 2005 05:02:48



Hi,
if I want to replace "X" with new line, on Linux I do:
echo aaaXbbb | sed 's/X/\n/g'
aaa
bbb
Which is what I want to do.

On Solaris I do same and get:
aaanbbb
output stream I don't get newline but letter "n".
Tried /usr/bin/sed and /usr/xpg4/bin/sed with same results.
Any idea how to replace something with newline ?

thanks
jmiklo

 
 
 

sed and new-line on Solaris broken ?

Post by Oscar del Ri » Wed, 13 Jul 2005 05:40:19



> if I want to replace "X" with new line, on Linux I do:
> echo aaaXbbb | sed 's/X/\n/g'
> aaa
> bbb
> Which is what I want to do.

> On Solaris I do same and get:
> aaanbbb
> output stream I don't get newline but letter "n".
> Tried /usr/bin/sed and /usr/xpg4/bin/sed with same results.
> Any idea how to replace something with newline ?

with an actual new line, escaped

echo aaaXbbb | sed 's/X/\
/g'

aaa
bbb

 
 
 

sed and new-line on Solaris broken ?

Post by Dragan Cvetkovi » Wed, 13 Jul 2005 06:15:34




>> if I want to replace "X" with new line, on Linux I do:
>> echo aaaXbbb | sed 's/X/\n/g'
>> aaa
>> bbb
>> Which is what I want to do.
>> On Solaris I do same and get:
>> aaanbbb
>> output stream I don't get newline but letter "n".
>> Tried /usr/bin/sed and /usr/xpg4/bin/sed with same results.
>> Any idea how to replace something with newline ?

> with an actual new line, escaped

> echo aaaXbbb | sed 's/X/\
> /g'

> aaa
> bbb

Or use tr(1).

Dragan

--
Dragan Cvetkovic,

To be or not to be is true. G. Boole      No it isn't.  L. E. J. Brouwer

!!! Sender/From address is bogus. Use reply-to one !!!

 
 
 

1. Help: use SED to move or replace "New-line" & "return" char


tempfile=/tmp/`basename ${0}.$$`

if [ $# -ne 1 ] ; then
        echo ${0}: I must have a file to work on
fi

if [ -r $1 ] ; then
        if [ -w $1 ] ; then
                sed -e 's/<imbeded c/r (or is is l/f?)>//' $1 > $tempfile
                mv $tempfile $1
        else
                echo ${0}: Sorry, I can\'t change $1
        fi
else
        echo ${0}: I can\'t read $1
fi

2. .profile and .kshrc being ignored

3. Linux math exception handling

4. sed: substitute a char with a line break

5. Time tracking, project planning, and billing, oh my!

6. removing line breaks with sed?

7. Compaq SVGA

8. line break after every occurance of ' or sed to work beyond 2048

9. A new line with sed

10. How to replace string with some text (with new lines) sed or something else ?

11. Substituting New Lines "\n" using an editor, i.e. ed or sed or vi?

12. Inserting a new line of text using SED