Reputation: 290
I want to substitute all the string define('DB_NAME', 'name_here');
with define('DB_NAME', 'myname');
in the file wp-config.php
.
x="define('DB_NAME', 'name_here');"
y="define('DB_NAME', 'myname');"
sed -i 's/$x/$y/g' wp-config.php
There is no error message in the console,but nothing happen.
How can i substitute all the string define('DB_NAME', 'name_here');
with define('DB_NAME', 'myname');
in the file wp-config.php
?
Upvotes: 0
Views: 53
Reputation: 41456
Its the single quote that makes the problem and make sed
does not evaluate your variable. Use double quote around the sed
code instead.
x="define('DB_NAME', 'name_here');"
y="define('DB_NAME', 'myname');"
sed -i "s/$x/$y/g" wp-config.php
PS to see what is going on, wait with -i
to you see output is correct.
sed "s/$x/$y/g" wp-config.php
define('DB_NAME', 'myname');
Upvotes: 2