Remove new line at the end of each line

"376964582","1","rotated","2010-05-06 12:40:47","1205847472","436201","444070","444070","sv","663","dm","Exceeded","2","2001","21","deer","10","21
"
"376964582","1","rotated","2010-05-06 12:40:47","1205847472","436201","444070","444070","sv","663","dm","Exceeded","2","2001","21","deer","10","21
"

I have newline chars at the end of the row, how do i remove them using awk ?

---------- Post updated at 05:40 PM ---------- Previous update was at 04:43 PM ----------

awk -F "," '$NF { a=$0; getline; $0=a$0 } 1 ' input.txt > output.txt

I tried the above but it worked only for few lines not to the end of the file. My file is huge.

Hi.

I did something similar:

$ awk '{print $0 "\""; getline}' file1
"376964582","1","rotated","2010-05-06 12:40:47","1205847472","436201","444070","444070","sv","663","dm","Exceeded","2","2001","21","deer", "10","21"
"376964582","1","rotated","2010-05-06 12:40:47","1205847472","436201","444070","444070","sv","663","dm","Exceeded","2","2001","21","deer", "10","21"

In sed:

$ sed "N; s/\n//" file1
"376964582","1","rotated","2010-05-06 12:40:47","1205847472","436201","444070","444070","sv","663","dm","Exceeded","2","2001","21","deer", "10","21"
"376964582","1","rotated","2010-05-06 12:40:47","1205847472","436201","444070","444070","sv","663","dm","Exceeded","2","2001","21","deer", "10","21"

 awk '{printf ($0~/"$/)?$0"\n":$0}' input.txt

Both the solutions works fine. If there is no data in the last column the script fails.

---------- Post updated at 07:32 AM ---------- Previous update was at 12:54 AM ----------

awk '{printf ($0~/"/)?$0"\n":$0}'

would simple ignore everything.

Any idea how to remove newline when there is no value

"376964582","1","rotated","2010-05-06 12:40:47","1205847472","436201","444070","444070","sv","663","dm","Exceeded","2","2001","21","deer","10","
"
cat file | tr -d '\015'

----

This wasn't the answer. Need to read ... but this is answer if somebody ask to how remove carriage return ..

Change ORS, default is newline. Here is ,. Do you need separator between lines or not ? If not, set ORS="".

awk 'BEGIN {  ORS="," }
{print $0}' file
cat filename|tr -d '\n' >filename.raw

If the input file is fixed-length records we could use "dd".

The conversion is a very strange operation to do because the converted file would be unreadable by any normal record based software.

It would help to know what the problem is with the original file?