Linux - SoftwareThis forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.
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.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Introduction to Linux - A Hands on Guide
This guide was created as an overview of the Linux Operating System, geared toward new users as an exploration tour and getting started guide, with exercises at the end of each chapter.
For more advanced trainees it can be a desktop reference, and a collection of the base knowledge needed to proceed with system and network administration. This book contains many real life examples derived from the author's experience as a Linux system and network administrator, trainer and consultant. They hope these examples will help you to get a better understanding of the Linux system and that you feel encouraged to try out things on your own.
Click Here to receive this Complete Guide absolutely free.
1) Embed a newline the old-fashioned way (this is good at the command-line, but not so much when doing this in a script);
Note that you have to basically press enter right after the backslash (some shells don't require a backslash).
Also, the ">" character is the default 'PS2' prompt (see the man page for ksh or bash).
xeleema @ SunOS $ echo "one,two,three" | sed -e 's/,/\
xeleema @ SunOS $
2) Use the 'tr' command if you are replacing just a single character;
xeleema @ SunOS $ echo "one,two,three" | tr ',' '\n'
xeleema @ SunOS $
Answer for "Why":
Early versions of 'sed' (and implementations that copied them) did not originally accept escaped characters in the Right-Hand-Side (RHS).
Information on this can be found in SourceForge's 'sed FAQ' online.
I've been unable to track down more information as to 'why' sed doesn't like dealing with '\n', I suspect Mr. McMahon might have been able to give us more guidance, had he not passed away in 1989.
The fact that sed has been around since about 1973 could have something to do with it.
I've seen older code with limitations built-in that reflected the current pre-existing limitations of various parts of an Operating system.
Once the Operating System improves, someone else has to go back and patch (or outright fork) the code and write-in improvements.
I'd imagine that's what the maintainers of GNU sed eventually wound up doing.