LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (http://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   merge multiple lines of a single file into one line (http://www.linuxquestions.org/questions/linux-newbie-8/merge-multiple-lines-of-a-single-file-into-one-line-173983/)

groverrajiv 04-24-2004 05:37 AM

merge multiple lines of a single file into one line
 
Dear

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

Rajiv

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

Unix
 
What about for Unix?

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

Thanks,

-a

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 03:51 PM.