0

I am trying to search in the root folder that contains a bunch of Joomla sites inside subfolders to have a sneak preview of the public $db variable of the configuration.php file of each site.

Note that the whole configuration.php consists of many such variables: Sample:

public $cache_handler = 'file';
public $cachetime = '15';
public $caching = '0';
public $captcha = '0';
public $cookie_domain = '';
public $cookie_path = '';
public $db = 'database_name';

I tried various options with grep, but either I get nothing or grep displays the contents of the whole configuration.php file of each subfolder.

grep -F -r "public $db" --include="configuration.php"

I suspect it might be related to the special characters in the search term, which somehow aren't treated as should, and grep finally searches for anything that contain "public"
-Whatever the case I need a bit of advise here on how to achieve this.

The final outcome I am after, is to get a list with the configuration.php files of each subfolder alongside with the whole line e.g. "public $db = 'database_name';" of text where the public $db variable exists.

e.g.

/folder1/configuration.php: public $db = "db1";
/folder2/configuration.php: public $db = "db2";
/folder3/configuration.php: public $db = "db3";
2
  • that worked mate... obvious things are often overlooked! Thanks!
    – FFrewin
    Apr 20, 2018 at 10:20
  • 1
    @dsstorefile Post that as an answer, please and thanks
    – wjandrea
    Apr 20, 2018 at 17:44

1 Answer 1

0

Your shell is parsing the $db as a variable and it's probably expanding to nothing. Change the double quotes to single quotes so grep gets the literal input.

0

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .