Need help on awk/sed/ perl pattern with regex / grep
- by Jayakumar K
Sample file output from grep
file1:my $dbh = DBI->connect("dbi:mysql:$database_name", $DB_USER, $DB_PASSWD)
file2:($dbc,$rc) = mysql_connect($mysql_host,$mysql_user,$mysql_password);
The awk pattern should get values databasename, DB_USER And DB_PASSWD from line 1
and mysql_host,mysql_user and mysql_password from line 2
i.e all variables inside the function.
Then it should search for the declaration of that variable in file before : (semicolon)
ex: databasename in file1 may be
$databasename = "dbweb" ;
ex: mysql_user in file2 may be
$mysql_user="root" ;
Result: It should display variable declarations of all 6 variables along with filenames
file2:$mysql_host = "db1";
file2:$mysql_user = "root";
file1:$DB_USER = 'user';