sed substitution within bash script with mixed quotes
sed substitution within bash script with mixed quotes
(OP)
I am trying to update some legacy php code via some sed substitutions running in a bash script.
Some items seem to work fine; others not so much. The issue appears to be when the substitution strings contain single or double quotes.
I have tried a variety of means of escaping the quotes; but, have had no success.
Here is an example line from my bash script:
I wish to replace: session_is_registered('ADMIN')
With: $_SESSION["group_code"]=='ADMIN'
Other substitutions without quotes in the string are working fine...
TIA,
-Allen M.
Some items seem to work fine; others not so much. The issue appears to be when the substitution strings contain single or double quotes.
I have tried a variety of means of escaping the quotes; but, have had no success.
Here is an example line from my bash script:
/usr/bin/sed -i 's/(session_is_registered('ADMIN')/$_SESSION["group_code"]=='ADMIN'/g' /home/impact/php_repair_temp/*.php
I wish to replace: session_is_registered('ADMIN')
With: $_SESSION["group_code"]=='ADMIN'
Other substitutions without quotes in the string are working fine...
TIA,
-Allen M.
RE: sed substitution within bash script with mixed quotes
CODE --> command line
Alternatively you can just move the Sed code to a Sed script file to avoid shell quoting problems :
CODE --> command line
CODE --> transform-my-code.sed
Feherke.
feherke.github.io