1

I have a shell file which needs to perform a replace of some text in a php file.

The line that needs replacing is:

$database = $db."_db"; 

The actual sed command needs to contain a variable so not sure what i should be escaping and where?

#!/bin/sh sed -i s/$db."db"/$DATABASE/ mysql_connect.php 

Thanks.

1 Answer 1

3

Enclose the string in single quotes to prevent variable expansion.

sed -i s/'$db."_db"'/$DATABASE/ mysql_connect.php 

to replace all occurrences of $db."_db" with the value of $DATABASE.

0

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.