how to find the last instance of a setting in a config file
Posted
by
Glenn Kelley
on Stack Overflow
See other posts from Stack Overflow
or by Glenn Kelley
Published on 2010-12-27T23:56:31Z
Indexed on
2010/12/28
7:53 UTC
Read the original article
Hit count: 310
I am trying to figure out how to find the last entry of a string in multiple config files across a server. Each of the strings will be in the /home/***usernamewouldbehere/public_html/typo3conf/localconf.php file
In short - the last entry in the config files will point to the database server the application is utilizing - and we need to know which accounts point to which db server.
While I can run something like this -
grep "$_db_host" /home/*/public_html/conf/localconf.php
It does not really help much because it gives us way to much information ... and not what we really need.
What i really need to know is the last entry of this string $_db_host = 'xx'; and to sort them out in an export file
Since the config files may have multiple entries (example below)
$_db_host = 'localhost';
$_db_host = '10.0.1.234';
It would be great to list in a file all of those that have the entry for 'localhost' and then list all of those that have the entry for '10.0.1.234' (or whichever server there may be there) but even if I need to do that manually that would be great.
I am not sure how to get to it using Awk - ... and really stuck
What I am hoping for is something that would be piped as follows
db_host = localhost /home/username1/www/conf/localconf.php
db_host = localhost / home/username2/public_html/conf/localconf.php
db_host= '10.1.2.23' /home/username55/public_html/conf/localconf.php
hoping that helps you help me :-)
© Stack Overflow or respective owner