LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (http://www.linuxquestions.org/questions/programming-9/)
-   -   Combine the Carriage Returns into one line (http://www.linuxquestions.org/questions/programming-9/combine-the-carriage-returns-into-one-line-733036/)

yuanjunliang 06-15-2009 09:28 AM

Combine the Carriage Returns into one line
 
I want to remove the "\+ Carrige Return" in the following text file:

id|column1|column2|comment|
1|aaa|bbb|he is great|
2|aa2|bb2|she is good|
3|aa3|bb3| fgf\
fgf\
gg|
4|aa4|bb4|bbb\
nnn\|
5|aa5|bb5|gggg|


After convert:

id|column1|column2|comment|
1|aaa|bbb|he is great|
2|aa2|bb2|she is good|
3|aa3|bb3| fgf fgf gg|
4|aa4|bb4|bbb nnn|
5|aa5|bb5|gggg|

colucix 06-15-2009 09:37 AM

Code:

sed -i.bck -e :label -e '/\\$/N; s/\\\n/ /; t label' file

yuanjunliang 06-15-2009 10:04 AM

Colucix, Thank you very much.


All times are GMT -5. The time now is 03:20 PM.