Other *NIXThis forum is for the discussion of any UNIX platform that does not have its own forum. Examples would include HP-UX, IRIX, Darwin, Tru64 and OS X.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
I figured I'd try responding without having a good answer.
My guess is that since Linux does not have a true Bourne Shell then this may be a difference between the true Bourne Shell and bash.
I would look for a common syntax for the command. For instance the following code is different than yours and it works on Linux. I don't have an HP-UX machine to test it on.
Code:
echo "absolut balogne." | sed "s/ /\n/"
Last edited by stress_junkie; 07-27-2007 at 04:38 PM.
Sed Regular Expressions
The regular expressions used in sed, by default, are basic regular
expressions (BREs, see re_format(7) for more information), but extended
(modern) regular expressions can be used instead if the -E flag is given.
In addition, sed has the following two additions to regular expressions:
1. In a context address, any character other than a backslash (``\'')
or newline character may be used to delimit the regular expression.
Also, putting a backslash character before the delimiting character
causes the character to be treated literally. For example, in the
context address \xabc\xdefx, the RE delimiter is an ``x'' and the
second ``x'' stands for itself, so that the regular expression is
``abcxdef''.
2. The escape sequence \n matches a newline character embedded in the
pattern space. You can't, however, use a literal newline character
in an address or in the substitute command.
Try your first example in Linux using single quotes or use a sed script. I'm not at my Linux computer now so I can't try it.
The second example is using Linux, isn't it? It is behaving now the same as the the UX example did. I think that the "\n" is being changed to an actual return character before being read in by sed.
OK, I tried it both ways in Linux. A newline was inserted. The difference is in the sed command itself. The paragraphs I quoted don't exist in the GNU sed manpage.
Distribution: Solaris 9 & 10, Mac OS X, Ubuntu Server
Posts: 1,189
Rep:
Solaris treats the \n in sed the same as HP/UX.
I learned sed and have always used it as an editor that works within individual lines within files. ^ and $ delimit the beginning and end of lines; but, for example, 's/^18//g' just removes the 18 from the beginning of the line, it does not remove the beginning of the line.
The Gnu/Linux example is probably an extension of the tradional functionality.
I just jump to other tools when one doesn't quite do it -- grep, tr, sed, awk, sort, uniq, etc. and then on to perl snippets. Although I agree it can be annoying when a really simple solution turns out not to be.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.