Getting sed to substitute a newline on Linux and Solaris hosts
While crafting an install script a week or two ago, I came across an annoying issue with the Solaris sed utility. When I tried to substitute the string ‘, ‘ with a newline, I got this:
$ grep foo gemlist | sed -e ‘s/foo.*(//’ -e ‘s/)//’ -e ‘s/, /\n/g’
2.4n2.3n2.2n2.1
But when I ran the same sustitution with GNU sed, everything worked as expected:
$ grep foo gemlist | gsed -e ‘s/foo.*(//’ -e ‘s/)//’ -e ‘s/, /\n/g’
2.4
2.3
2.2
2.1
It turns out that the Solaris sed is extremely dated, and requires an explicit newline instead of a ‘\n’:
$ grep foo gemlist | gsed -e ‘s/foo.*(//’ -e ‘s/)//’ -e ‘s/, /\
$>/g’
2.4
2.3
2.2
2.1
In the end I found it easier to write my installer in Python, which made life much much easier.








Ex-Solaris User on May 16th, 2009
Solaris vi is also dated.