As you know in Drupal there is a settings.php file with database connector.
$db_url = ‘mysql://username:password@localhost/databasename’;
I would like a shell script to extract the string which is the ‘databasename’ and echo it.
Help is much appreciated.
Thanks
You can use:
The first line searches settings.php for db_url, and then pipes that into cut that removes all text before the first 3 slashes. Finally the last ‘: is removed from the end of the variable and it is echoed. This code is very dependant on the format of the url, it relies on the fact that there will always be 3 slashes before the database name.