find locate files
find walks through directories and lists the files that match your tests: name, type, modification time, size and more. It can also run a command on each match.
Availability Preinstalled on macOS, Linux and BSD
Syntax
find [path ...] [tests] [actions]
Common options
| Option | What it does |
|---|---|
-name 'pattern' | Match the file name (use -iname to ignore case) |
-type f / -type d | Only files, or only directories |
-mtime -1 | Modified within the last day |
-size +100M | Larger than 100 MB |
-maxdepth N | Don't descend more than N levels |
-exec cmd {} + | Run a command on the matches |
-print0 | Separate results with NUL, for xargs -0 |
Examples
All CSV files under the current folder
find . -name '*.csv'
Logs changed in the last day
find /var/log -type f -mtime -1
Big files
find . -type f -size +100M
Compress every log file
find . -name '*.log' -exec gzip {} +
Use find with sqx
Query every JSON Lines file in a tree
find logs -name '*.jsonl' -exec cat {} + | sqx "SELECT type, COUNT(*) FROM stdin GROUP BY type"
Quote patterns like '*.csv' so the shell passes them to find instead of expanding them itself.
Full documentation
This page covers the essentials. For every option, see the official documentation:
Or read the manual in your terminal: man find