Skip to content

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.

A practice shell in your browser that behaves like bash on Linux for these commands. Nothing you type leaves the page.

Usage

find [PATH]... [EXPRESSION]

Options

-name PATTERNthe file name matches PATTERN (* ? and [ ] work as in the shell)
-iname PATTERNlike -name, ignoring case
-type fregular files only
-type ddirectories only
-maxdepth Ngo no more than N levels below the starting path
-mindepth Nskip the first N levels
-emptyempty files and empty directories
! or -notnegates the next test, as in ! -name "*.log"

Examples

  • find . -name "*.txt"Every .txt file below here
  • find ~ -type d -name configFolders called config in your home
  • find /var/log -maxdepth 1 -type fFiles directly inside /var/log

Learn it step by step