I'm coding using BASH and have a requirement to replace apostrophes with backslash apostrophes. For example below:
I am here 'in my room' ok
Would be changed to:
I am here /'in my room/' ok
The original text is coming from a field in a MySql database and is being used by another process that REQUIRES a backslash in front of all apostrophes, thus I am unable to change that process at all.
in BASH I read the value from MySql and place it in a variable:
MyVAL="mysql command and query which only returns one value"
I have been successfully replaced double quotes with back slash double quotes but the apostrophe is a heck of a challenge.
How I do the double quotes is with this:
xMyVAL=`echo $MyVAL | sed -e 's/\"/\\\"/g'`
I hope this can be done easily with sed.