When I search for some files under a dir, I run

find dir -name pattern

But I find that the following will return all the files under dir, regardless what pattern is:

find pattern dir

is it just like tree dir? Why is it?


2 Answers 2


find can take many dirs as arguments:

find dir1 dir2 dir3 -name pattern

so find patern dir just lists everything inside two directories: pattern and dir.


In find, when you use the -name that means only output files with that name as a result

  • What does find pattern dir do?
    – Tim
    Oct 19, 2014 at 22:02
  • as in find foo.sh /? where foo.sh is the file being looked for and / is the directory?
    – jgr208
    Oct 19, 2014 at 22:03
  • It list all the the contents and subcontents of dir here. pattern doesn't matter.
    – Tim
    Oct 19, 2014 at 22:05

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .