Skip to Main Content

Infrastructure Software

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

sed ignoring escape characters

807557Oct 31 2007 — edited Nov 6 2007
Hello,
I am trying to port over some code from Linux (ubuntu 7.4) to Solaris 9 and 10. One of the commands uses \r and \n to work but the command isn't working as expected from Linux.

Linux Code (What I expect to happen):
$cat file.txt
abc def ghi
jkl
mno
pqr
$cat file.txt | sed 's# #\n#g'
abc
def
ghi
jkl
mno
pqr
$cat file.txt | sed 's#\n# #g'
abc def ghi jkl mno pqr
Solaris 9 and 10 (What happens)
$cat file.txt
abc def ghi
jkl
mno
pqr
$cat file.txt | sed 's# #\n#g'
abcndefnghi
jkl
mno
pqr
$cat file.txt | sed 's#\n# #g'
abc def ghi jkl mno pqr
So, it's recognizing that \ is an escape character but it's not substituting in the NEWLINE character.

What am I doing wrong?

How could I implement this correctly?

Thank you very much for your help,

BRISKbaby
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Dec 4 2007
Added on Oct 31 2007
14 comments
767 views