replace character with '

ive tried doing
sed -i 's/h/\'/g' file.txt
to replace h with ' but it doesnt work:confused:. Any ideas would be greatly appreciated.

I have opposite problem. I want to replace ' with null
e.g: change 123, abx'
to 123, abx

Any idea.

Thanks in Advance

echo "123, abx'" |sed s/\'//g

to reverse it

echo "123, abx" |sed s/abx/\'abc/g

just remove ' before s and next to g

I figured it out. Instead of
sed -i 's/h/\'/p' file.txt
I used
sed -i "s/h/'/p" file.txt
and it worked :slight_smile: