How to change only one occurance of apostrophe with sed

Hi,

I have a document with usual English text and some of the words have apostrophes (e.g. don't, can't, etc.)

I would like all these apostrophes to be doubled (e.g. don''t, can''t, etc.), but the problem is, that some of such words have double apostrophe and

by using sed -i "s/'/''/g" it would end up with for apostrophes (e.g. don''''t, etc.)

For now I have a work around that first I change one to two apostrophes and then four to two, but I would like to do it in a clean way.

Thanks for suggestions.

Pavel

 
bash-3.00$ sed "s/\'/&&/g" /tmp/myfile
don''t
dont''t
bash-3.00$ cat /tmp/myfile
don't
dont't

Here the regex matches only string <non-quote><quote><non-quote>.

It would have been more appropriate to post this question in 'scripting' forum.