Suppressing space replacing by comma

hi

i want to replace spaces by comma
my file is

ADD     16428   170     160     3       WNPG    204     941     No      204802
ADD     16428   170     160     3       WNPG    204     941     No      204803
ADD     16428   170     160     3       WNPG    204     941     No      204804
ADD     16428   170     160     3       WNPG    204     941     No      204831
ADD     16428   170     160     3       WNPG    204     941     No      204832
ADD     16428   170     160     3       WNPG    204     941     No      204833
ADD     16428   170     160     3       WNPG    204     941     No      204837
ADD     16428   170     160     3       WNPG    204     941     No      204853
ADD     16428   170     160     3       WNPG    204     941     No      204862

i want it like

ADD,16428,170,143,1,WNPG,204,242,No,204208
ADD,16428,170,143,1,WNPG,204,242,No,204216
ADD,16428,170,143,1,WNPG,204,242,No,204242
ADD,16428,170,143,1,WNPG,204,242,No,204245
ADD,16428,170,143,1,WNPG,204,242,No,204246
ADD,16428,170,143,1,WNPG,204,242,No,204312
ADD,16428,170,143,1,WNPG,204,242,No,204313
ADD,16428,170,143,1,WNPG,204,242,No,204319
ADD,16428,170,143,1,WNPG,204,242,No,204324

please let me know ..

 
tr " " "," < input_file

try

 sed 's/\s/,/g' file_name

Both are not working !

They're not working because you didn't use code tags, and your formatting was therefore removed.

sed "s/  */,/g" inputfile

what ever solution is posted as per your previous requirement. But u changed the space with multiple space..
now you can try

sed 's/\s\+/,/g' file_name

Hi

If your input file is tab delimited then try this.

tr '\011' ',' < filename

and If it is space delimited then

tr -s ' ' ',' < filename

You changed your input file on a fly and both the solutions were suggested for your previous input file

if your input if tab delimited , then

tr "\t" "," < input_file

dnt know why it is not working

tried with /usr/bin/sed still the same ..

---------- Post updated at 08:06 AM ---------- Previous update was at 08:00 AM ----------

Thanks all tr "\t" "," < inputfile > r6.txt is working !

try this

sed 's/[ ,\t]/,/g' input_file