Reputation: 7515
I am trying to do the following search and replace, but for some reason it's not working. I am trying to replace:
require_once('
with
require_once($_SERVER['DOCUMENT_ROOT']/'
Those are the exact srings (slash and single quote included).
This is what I attempted, however I can't get it to work:
find ./ -type f -readable -writable -exec sed -i "s/require_once(\'/require_once($_SERVER['DOCUMENT_ROOT'] . \'\//g" {} \;
What am I doing wrong??
Upvotes: 4
Views: 359
Reputation: 189387
You need to backslash-escape the dollar sign within double quotes, otherwise the shell interpolates the (nonexistent) environment variable _SERVER
, replacing it with an empty string.
Upvotes: 0
Reputation: 689
You need to escape the $
and /
characters:
sed "s/require_once('/require_once(\$_SERVER['DOCUMENT_ROOT']\/'/g"
Upvotes: 5