LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Remove a new line character (https://www.linuxquestions.org/questions/linux-newbie-8/remove-a-new-line-character-717927/)

kbmukesh 04-09-2009 08:40 AM

Remove a new line character
 
Hi,

i have a file which looks like this:

49888 Incorrect location
2009-03-30
444789 Missing issue
2009-04-12
658971 Resolution
2008-12-08

and expect the output to be like this:

49888 Incorrect location 2009-03-30
444789 Missing issue 2009-04-12
658971 Resolution 2008-12-08

please help me out. i tried sed new line removal but it appends everything to a single line.

onebuck 04-09-2009 08:44 AM

Hi,

Welcome to LQ!

Post what you have tried.

colucix 04-09-2009 09:37 AM

You can try the N command of sed to read the next line and add it to the pattern space, separated by newline. Then change the newline with a space and it will output every two lines in a single one:
Code:

sed '$!N;s/\n/ /' file

kbmukesh 04-13-2009 01:41 AM

Thx colucix. That's exactly what i was looking for.


All times are GMT -5. The time now is 10:54 AM.