Ask Ubuntu is a question and answer site for Ubuntu users and developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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?

share|improve this question

If your shell is zsh or bash:

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

(** expands to any depth of subdirectories.)

share|improve this answer

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" {} \;
share|improve this answer
find . -name '.htaccess' -print | xargs grep 'common.php'
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.