How to "find" both regular files and directories?

Here is the command you can use:

find -type f -or -type d

tl:dr

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

explanation

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).

Tags:

Find