Remove the last character (,) for every line in a file

Good afternoon:

im working wih 2 files to find differences and use the cmp command

cmp file1 file2
file1 file2 are are diifferent char 302 line1

i found what the difference is with the sed command and that is the file1 at the end of every line has a (,) (comma) character.
i.e

sed -n l file1|head -5
,1790365,1,F,1,01,00,20121205,23305300,17.00,0000001700,03214534032,0\
3187170198,I,,0,,,N,I,20121207 001649,EDFN,,,0,I,STD,COMCE,BSC,COMBOG\
EG,TAND,27,0404,MOB-315,ENT,ENT-MOB,MM01,Telefonos de BSC,N,0,T_D,1,1\
.00,60.00,17.00,MINRED,1,COMCE,TO,PCO,0.000000,0.000000,MINUTO,1.00,1\
,0.000000,0.00,0.00,,0.00,\r$
sed -n l file2|head -5
1790365,1,F,1,01,00,20121205,23305300,17.00,0000001700,03214534032,0\
3187170198,I,,0,,,N,I,20121207 001649,EDFN,,,0,I,STD,COMCE,BSC,COMBOG\
EG,TAND,27,0404,MOB-315,ENT,ENT-MOB,MM01,Telefonos de BSC,N,0,T_D,1,1\
.00,60.00,17.00,MINRED,1,COMCE,TO,PCO,0.000000,0.000000,MINUTO,1.00,1\
,0.000000,0.00,0.00,,0.00\r$

I want to remove the last character (,or comma) in every line for file1, dont know much about sed and i tried with the following:

sed 's/,$//g' file1 > file4

the above command was likely to work but it didnt since i run the the cmp command yieldiing the same error in the same line and character:

cmp file1 file4
file1 file2 are are different char 302 line1

Id appreciate your help in advanced

I see a comma at the beginning as well, try this command:-

sed 's/^,//g; s/,...$/\\r\$/g' file1 > file4

thanks, but the last command remove the comma at the beginning but at the end of the line remains but what i want is just to remove the last comma before the r$ character (End of line). this is the output

sed -n l file4|head -5
1790365,1,F,1,01,00,20121205,23305300,17.00,0000001700,03214534032,03\
187170198,I,,0,,,N,I,20121207 001649,EDFN,,,0,I,STD,COMCE,BSC,COMBOGE\
G,TAND,27,0404,MOB-315,ENT,ENT-MOB,MM01,Telefonos de BSC,N,0,T_D,1,1.\
00,60.00,17.00,MINRED,1,COMCE,TO,PCO,0.000000,0.000000,MINUTO,1.00,1,\
0.000000,0.00,0.00,,0.00,\r$

Id appreciate your help thanks in advanced

---------- Post updated at 09:57 PM ---------- Previous update was at 08:17 PM ----------

furthermore i tested to substitute with a string and then grep it and i couldnt find the substitution i.e

sed 's/,$/TestStr/g' file1 > file4

grep -i TestStr  file4
found nothing

now another doubts arises: this is a 100000 records file i want to process, and im working with ubuntu 10.1 with bourne shell and then want to run in a HP unix,so dont know if the version of the sed command has something to do ?

please do a dos2unix on source files first. It is confused to work on a DOS-format file in Unix env.

dos2unix file1 file1
dos2unix file2 file2

OK ive got it, i run the same command (sed 's/^,//g; s/,...$/\\r\$/g' file1 > file4) in the server HP-UX and work it out succesfully working with the same file. the server is :
HP-UX proetldb01c B.11.31 U ia64 4072542272 11 but in my computer with Ubuntu installed didnt work. So the problem has something to do with the version of sed in Ubuntu ?