Simple command “find” not working

find

so I'm in the main folder for my web hosts, trying to find a file using find. I couldn't find it – it was listed as no such file or directory – and I thought maybe it isn't anywhere.

However the following command doesn't work either:

find index.php

which is wrong cause there are a gazillion of them. Why is find not working? Is there a better command to use?

Best Answer

The syntax of find is not like what you have written, please read the manual page man find to get detailed idea.

For example if you want to find files named index.php on the current directory and all the sub directories under it, you can use:

find . -name index.php -type f 

If you want to search for files having names say findex.php, index.phpfoo, index.php you need to use:

find . -name '*index.php*' -type f 

* is a glob pattern meaning zero or more characters.

On the other hand if you want to look in the current directory only :

find . -maxdepth 1 -name '*index.php*' -type f 
Related Question