How do I replace single quotes with another character in sed?

This will do what you want to

echo "hari's"| sed 's/\x27/ /g'

It will replace single quotes present anywhere in your file/text. Even if they are used for quoting they will be replaced with spaces. In that case(remove the quotes within a word not at word boundary) you can use the following:

echo "hari's"| sed -re 's/(\<.+)\x27(.+\>)/\1 \2/g'

HTH


Just go leave the single quote and put an escaped single quote:

sed 's/'\''/ /g' input

also possible with a variable:

quote=\'
sed "s/$quote/ /g" input

Try to keep sed commands simple as much as possible. Otherwise you'll get confused of what you'd written reading it later.

#!/bin/bash
sed "s/'/ /g" myfile.txt