Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

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

3 Answers 3

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

 
discard

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.