2

I need to perform a search for "foo" and return all the filenames/directories with this name (e.g. foo.php, foo.txt etc). It should run through the whole filesystem and find even hidden files. I've tried find / -name 'foo' but doesn't seem to work.

4

find's -name operator uses shell-style wildcards, so

find / -name 'foo.*' -o -name '.foo.*'

would find foo.php foo.txt or hidden files like .foo.php etc. -o means "Or", without it a file would have to have both names. Use -iname if you want case insensitive matching.

  • cept that isn't going to find hidden files – Mike Jan 15 '13 at 13:58
  • ohh stupid me ... it was so easy – user154523 Jan 15 '13 at 14:00
0

use -regex option which is applied to the full path of each file / dir / socket etc tested

find / -regex '.*foo\.(php|txt|iso)'

should work for hidden files too.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.