Searching by file name

The find utility is the one of the primary ways of finding files and directories in Linux.

The general syntax is:

find [<flags>] <path> <search-expression>

A number of optional flags are available to fine-tune the search.

Common use cases

Find a file by name in the current directory recursively.

The -name flag can be used for searching a file by name in a case-sensitive manner.

E.g.:

# By exact filename:
find -name . config.js

# By file extension:
find -name . *.js

# By filename pattern:
find -name . config*

The -name flag can be replaced by -iname to search in a case-insensitive manner.

E.g.:

# By exact filename in case-insensitive manner:
find -iname . readme*