Place a comma on lines

Is it possible to place a comma in the desired places, like 10spaces after or 15 spaces after, irrespective of the contents???

Ex:File: TEST

TEST:

vimalthomaswants to place a comma
can he do it in the desired places?

as per the above file, i need to place a comma after 10th space irrespetive of the content can i do this??

Expected output:

vimalthoma,swants to place a comma
can he do i,t in the desired places?

Hi,

try:

sed 's/^\(.\{10\}\)\(.*\)/\1,\2/' file

HTH Chris

It works well thanks a lot
can u explain the same?? and how can i bring commas in different places at a time

like "vimal,thomas,wants to know,"

sed 's/^\(.\{10\}\)\(.*\)/\1,\2/' file

s/a/b/ -- substitute a with b
^ -- beginning of a line
.\{10\} -- "." matches anything, \{10\} ten occurences of "."
\(...\) -- saves the match in the registers \1 to \9

Thus to add a comma after the 10th, 20th and 30th charachter.

sed 's/^\(.\{10\}\)\(.\{10\}\)\(.\{10\}\)\(.*\)/\1,\2,\3,\4/' file

HTH Chris

Thank you sir... It is really rocking!!!