-   Linux - Newbie (
-   -   merge multiple lines of a single file into one line (

groverrajiv 04-24-2004 05:37 AM

merge multiple lines of a single file into one line

I would like to merge two or more line of a single file into one line, can some body help me


whansard 04-24-2004 06:52 AM

it depends on how the line is terminated.
you can look at it with cat -A <file>
unix text will end with $
dos text will end with ^M$

tr '\012\015' '' < filenamefrom > filenameto

will remove carriage return newline from a dos text file

edit: i think that should have been

tr -d '\012\015' < filenamefrom > filenameto

jeremy 04-24-2004 06:04 PM

Moved: This thread is more suitable in Linux - Newbie and has been moved accordingly to help your thread/question get the exposure it deserves.

guest 05-25-2004 06:34 PM

What about for Unix?

What I cat -a FILE I get a $ at the end of the line.



whansard 05-26-2004 02:38 AM

do you just want to remove the newline, or do you want it replaced with a space character?

tr -d '\012' < infile > outfile
removes it
tr '\012' ' ' <infile>outfile
replaces with a space

looks like i made a mistake in my answer above.

All times are GMT -5. The time now is 09:26 AM.