Find files by name
Searches every subdirectory for filenames matching a case-insensitive pattern, quoted so the shell hands the wildcard to find untouched.
Last updated
find . -iname "*.log"
How it works
-iname matches case-insensitively — plain -name is case-sensitive, so it would miss "error.LOG" or "Error.Log" while -iname catches all of them with one pattern. The quotes around "*.log" are what make this actually recursive: an UNQUOTED *.log gets expanded by the shell itself, against files in the current directory only, before find ever sees it — so find would receive a list of literal filenames (or nothing, if none exist right there) instead of the pattern to search with.
. as the starting path means "search here and every subdirectory beneath it," which is find's default recursive behavior with no depth limit unless you add one.
Watch out for
- →Quoting the pattern isn't a style choice here — it's the difference between a working recursive search and one that silently searches nothing beyond the current directory, because of how the shell's own globbing runs before find gets a chance to see the raw pattern.
- →-iname is a widely supported extension on both GNU find (Linux) and BSD find (macOS), but it's not part of the strict POSIX find specification — a minimal or embedded find (some containers, busybox) may only support the case-sensitive -name.
- →This starts at . and searches every level below it by default; add -maxdepth 1 to restrict the search to just the current directory, or swap . for a different starting path to search elsewhere.