The find command
Search for files in a directory tree. Walks through each PATH (the current directory if you give none), and every folder inside it, printing the paths that match the expression. Put patterns in quotes, as in -name "*.txt", so the shell passes the * to find instead of expanding it first.
Usage
find [PATH]... [EXPRESSION]
Options
| -name PATTERN | the file name matches PATTERN (* ? and [ ] work as in the shell) |
|---|---|
| -iname PATTERN | like -name, ignoring case |
| -type f | regular files only |
| -type d | directories only |
| -maxdepth N | go no more than N levels below the starting path |
| -mindepth N | skip the first N levels |
| -empty | empty files and empty directories |
| ! or -not | negates the next test, as in ! -name "*.log" |
Examples
find . -name "*.txt"Every .txt file below herefind ~ -type d -name configFolders called config in your homefind /var/log -maxdepth 1 -type fFiles directly inside /var/log
Learn it step by step
Related commands
learner@sandbox: ~bash (practice)
Note: Try find here: your home directory has sample files. Press Try beside an example, or type your own.
Enter runs · Tab completes names · ↑ ↓ step through history · Ctrl+L clears · type help for every command
A practice shell in your browser that behaves like bash on Linux for these commands. Nothing you type leaves the page.