3

How would I find all the .htaccess files (recursively from current folder) that contain a particular string ('common.php') in my case?

What would be the command to do so?

3 Answers 3

1

If your shell is zsh or bash:

grep 'common\.php'  **/.htaccess

(** expands to any depth of subdirectories.)

1

This command will search all files in the current directory for that string:

grep -r "common.php" .

This had the advantage of it gives the filename - a better thing will probably be in @Rmano 's answer.

This will search for the .htaccess file, then run grep on it.

find . -type f -iname '.htaccess' -exec grep -r "common.php" {} \;
1
find . -name '.htaccess' -print | xargs grep 'common.php'

You must log in to answer this question.

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