Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Grep a string recursively in all .htaccess files

How can I grep for a certain string recursively in all .htaccess files?

grep -r -n -H -I 'string' .htaccess

doesn't seem to work.

I'm on a GNU Linux system.

like image 716
Han Avatar asked Dec 09 '22 19:12

Han


2 Answers

cd to a folder before the folders that store the htaccess

$find . -name ".htaccess" -exec grep -r -n -H -I 'string' {} \;
like image 59
Ryan Fernandes Avatar answered Jan 01 '23 15:01

Ryan Fernandes


Use the --include option:

grep -rnHI 'pattern' --include=.htaccess .
like image 21
Adam Rosenfield Avatar answered Jan 01 '23 15:01

Adam Rosenfield