I want to find all PHP scripts that are inside a directory named web
. In particular, I'm interested in any files named index.php
in any of these directories.
I know that I can use sudo find / -type d -name "web"
to list all the directories, and then I can use sudo find <directory path> -type f -name "*.php"
for each of the output paths, to see if it contains a PHP script.
But is there a way to do this in one line and two nested find commands: one find command used to get the paths to the web
directories, and the second to use each of those directories in turn as the root for finding a file whose name matches the pattern *.php
?