Having some difficulty in replacing some single/double quoted text with sed and was wondering what\'s the correct method for these 2 examples
to change
You either need to quote the quotes or escape the quotes. Did you try checking what sed sees when you give it that last command?
sed -i 's/'ADMIN_USERNAME','memcache'/'ADMIN_USERNAME','u'/g' /var/www/html/memcache.php
Try this:
echo sed -i 's/'ADMIN_USERNAME','memcache'/'ADMIN_USERNAME','u'/g' /var/www/html/memcache.php
It gives this:
sed -i s/ADMIN_USERNAME,memcache/ADMIN_USERNAME,u/g /var/www/html/memcache.php
Oops! Your single quotes were not interpreted how you thought. An easy workaround for this case is to quote protect your sed command from the shell with double quotes instead.
sed -i "s/'ADMIN_USERNAME','memcache'/'ADMIN_USERNAME','u'/g" /var/www/html/memcache.php