Tag Info

New answers tagged

1

The recursive grep will scan the entire tree and not care about directory structure. You need to traverse the structure and grep each directory individually. find /var/www -type d -print | while read dirname; do grep -sil '<?' "$dirname"/*.php | head -3; done The grep -s will handle conditions where there are no php files in a directory.


0

What about something like this? for DIR in $( find ./test -mindepth 1 -type d ); do find "$DIR" -type f | grep "\.php" | head -n3 done find ./test -mindepth 1 -type d lists all the directories in the test directory excluding the parent. find "$DIR" lists the full path in each directory and then greps for the php extension and lists three with head. ...



Top 50 recent answers are included