Jens Knoell wrote: > Oke... sed-hell again. > > Case: I have a file that has lines separated by pipe chars. I need to split > it back into a line-by-line file. So I tried this (the ^M has been entered > by pushing Ctrl+V, Enter): > echo "This|should|be|on|separate|lines" | sed -e "s/|/^M/g" > > The result: > linesate > > I'm sure I'm missing something, but hours of googling didn't get me > anywhere. Any ideas? The Unix line seperator is LF (ASCII 10, ^J), not CR (ASCII 13, ^M). Sending a lone CR to a terminal will simply move the cursor to the begnning of the line, so you are seeing all of the lines printed on top of each other ("separate" is the longest line, so it overwrites everything; "lines" then overwrites the first 5 characters of "separate", leaving "linesate" on the terminal). What you actually want is: echo "This|should|be|on|separate|lines" | sed -e 's/|/\^J/g' where the ^J is entered using Ctrl-V Ctrl-J. Note the use of single quotes rather than double quotes, and the backslash before the ^J. Both of these are necessary to prevent the LF being interpreted by either the shell or sed. -- Glynn Clements <glynn.clements@xxxxxxxxxx> - : send the line "unsubscribe linux-admin" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html