Basically I want to write a script that could automatically copy a Drupal 7 settings.php file and search/replace the database name with a different one.
Before starting with sed or something like that I've just been trying to grep out the database name, just to get the regular expression down.
So far I've had no luck, my best guess has been grep "'database' =>" settings.php
That gives me the output:
* 'database' => 'databasename',
* 'database' => 'databasename',
* 'database' => 'databasename',
* 'database' => 'databasename',
* 'database' => '/path/to/databasefilename',
'database' => 'MY_DATABASE',
I just want the last line 'database' => 'MY_DATABASE', but really just the name so ideally the output would just be MY_DATABASE.
Any thoughts?