LinuxQuestions.org

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

yuanjunliang 06-15-2009 08: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 08:37 AM

Code:

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

yuanjunliang 06-15-2009 09:04 AM

Colucix, Thank you very much.


All times are GMT -5. The time now is 09:24 PM.