Linux - NewbieThis Linux forum is for members that are new to Linux.
Just starting out and have a question?
If it is not in the man pages or the how-to's this is the place!
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.
Hi guys. I've been trying to figure out sed for some time with no success. The man pages are confusing at best and I've scoured the internet for help. I've read a few tutorials and getting started guides and things like that but I'm unable to get the right command to do what I want. All I want to do is take a list of IP addresses that are on consecutive lines and print them on the same line separated by commas to a new file. eg:
file "IP1.txt" looks like
and I want them to output to "IP2.txt" and look like this:
220.127.116.11, 18.104.22.168, 22.214.171.124, 126.96.36.199
If anyone can help me out with a sed one liner I would really appreciate it and you'd be saving me some more frustration trying to figure it out.
this isn't really something sed is good at without some meddling around. Sed works on data on a line by line basis, so you can't remove the carriage returns as sed never sees them. It's possible to mess with bash environmental variables to change what defines a new record, but this just isn't a good way to learn sed.
I'd use tr instead, which isn't line based... "cat file | tr '\n' ','"
I don't really know why sed!! hence the linux newbie forum! : )
Thanks everyone for the responses... the 'cat file | tr "\n" ","' command worked perfectly! I used to work with someone who accomplished this with 'sed', but lost the command he used. He was considerably smarter than me on computers. This command is so simple! I really appreciate the help! Thanks again!