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!
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.
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.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
Guys, this isn't a a homework assignment just not aware of how to format the output correctly. I was thinking of tr but not sure what tool will take each line and combine into a paragraph. Also perhaps sed could be used to put a space between each line in the list? I will take a look at the scripting document.
Well, maybe there are a lot of ways to do that. Some sed guru can provide a very short one-liner, but here is a simple solution using pure bash code:
Code:
#!/bin/bash
count=0
while read line
do
if [ $((count % 2)) -ne 0 ]
then
if [ -z $result ]
then
result=$line,$pre
else
result=$result,$line,$pre
fi
else
pre=$line
fi
((count++))
done < testfile # the name of the input file here
echo $result
"SED guru": Often defined as one who will go to great lengths to do things with sed, even though other tools are better.....
I think you can let SED read the lines and then append them to the hold register. Then, when the end of file is encountered, it dumps the hold register and prints. I'll try this when I can. Meanwhile the best SED tutorial is here: http://www.grymoire.com/Unix/
Another great sed replacement by pixellany. Pixellany do you make uber dollars? I have been patrolling for all sed tips on this forum and your solving problems on all of them. Are you a programmer? Just curious of what all senior members do for a living? Please give advise if possible and how long you have been working with sed to be able to solve almost any problem.
Last edited by keysorsoze; 12-02-2008 at 06:32 PM.
Thank you everyone for the help, I promise this was not a homework assignment I just did not want to use real data since it was sensitive.
Please no one reveal what this sed statement does I will try my best to decode it. I did not even know this was possible with sed. Pixellany do you make uber dollars? It seems like there is nothing you can't solve with sed. I will also work on explaining the shell script since it confused me as well.
Thanks for all the help, this forum is great.
But the OP was not nixlearn? keysorsoze, are you the same person?
"But the OP was not nixlearn? keysorsoze, are you the same person?
No I was initially going to repost the question and try my stab at solving two sed statements but did not want to embarass myself. So I edited my post. How do you guys put blue boxes on all your quotes.
Coluix are you a programmer? I am wondering because I am a sysadmin right now and I honestly don't know half of what you guys know how do you get to the level where you can solve virtually any problem members dish at you? I hope to get senior status one day.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.