How can I tell ( if I can tell !) find to find files of both the directory and file type?

find -type fd

It is like the heuristic dark ages up in here.


Here is the command you can use:

find -type f -or -type d
  • 7
    Or find -type f -o -type d for POSIX compliant alternative. – manatwork Nov 3 '12 at 14:54
  • Hey I ran into a little trouble with this when I run $find . -type d -or -type f -and -iname "vision" it does not do exactly what I expect, am I missing something else! – Arcabard Nov 3 '12 at 15:56
  • 2
    -a has precedence over -o, use parenthesis (but escape them for the shell). No need to use the non-standard -or or -and. – Stéphane Chazelas Nov 3 '12 at 16:52
  • if I try ` find . -type d or -type f -name 'abc'. I get an error.. find: paths must precede expression:`.. Any idea why? – alpha_989 Jul 1 '18 at 21:38
  • 1
    @alpha_989 missing - before or? – Mateusz Piotrowski Jul 1 '18 at 21:41


use find . -name "*string*" -type f -o -name "*string*" -type d


the -o command ors the arguments after the filepath completely, such that find . -name "*string*" -type f -o -type d computes find . (-name "*string*" -type f) -o (-type d). For this reason, you must specify the

Most users will want something that looks like

find . -name  "*string*" -type f -o -name "*string*" -type d

which computes as

find . (-name  "*string*" -type f) -o (-name "*string*" -type d)

find syntax details

-name "*string*" searches for names that contain the string string anywhere in them.


If you're using the GNU find then the following solution might suit you:

find -type d,f

See man find for more details:

To search for more than one type at once, you can supply the combined list of type letters separated by a comma , (GNU extension).

  • 1
    Using GNU find version 4.7.0.. It doesn't seem to support ,. The error message says that find: Arguments to -type should contain only one letter. – alpha_989 Jul 1 '18 at 21:37

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.