Search

find

Search for files and directories in a directory hierarchy with powerful filters.

Synopsis

syntax
find [PATH]... [EXPRESSION]...

Examples

Find all .log files recursively
find . -name '*.log'
Delete files older than 30 days
find /tmp -type f -mtime +30 -delete
Find files larger than 100MB
find . -type f -size +100M
Find JS files containing TODO
find . -name '*.js' -exec grep -l 'TODO' {} +
List directories one level deep
find . -maxdepth 1 -type d

Common options

FlagDescription
-nameMatch filename pattern
-typeMatch file type (f=file, d=directory)
-mtimeMatch by modification time in days
-sizeMatch by file size
-execExecute command on each match
-maxdepthLimit directory descent depth

About find

The `find` command search for files and directories in a directory hierarchy with powerful filters. Search commands help you locate files, text patterns, and executables across the filesystem.

Efficient searching is critical when working with large codebases or troubleshooting system issues. These tools range from simple filename lookups to full regular-expression pattern matching across file contents.

The command accepts 6 commonly used flags shown above, though the full set of options is available in the man page (`man find`). The 5 examples on this page cover typical real-world usage patterns that you can copy and adapt for your own workflows.

Related commands

More Search Commands

Other commands in the Search category

Related tools