LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   Join all lines using sed (https://www.linuxquestions.org/questions/programming-9/join-all-lines-using-sed-207396/)

chipix 07-20-2004 09:02 AM

Join all lines using sed
 
Hi,

what is the proper sed command in order to transform a multi-line file to a single line. For example:

input.txt:
mpla1
mpla2
mplampla mpla 3

output.txt:
mpla1 mpla2 mplampla mpla 3

Thanks

Hko 07-20-2004 09:24 AM

Read this thread:

http://www.linuxquestions.org/questi...hreadid=191121

chipix 07-20-2004 09:32 AM

Oh thx.

I did not know that my question was already answered. :rolleyes:

However, I found also this solution: http://www.student.northpark.edu/pem...aq4.html#s4.27

tr?? man, unix has a lot of commands!!:study:

sredden79 04-03-2007 09:55 AM

to spell this out for everyone the command you need to use to remove all the new line characters using sed is :

sed -e :a -e '$!N; s/\n/ /; ta' test.txt

hope this helps.


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