Bash 5 reference · Text and System Tools
find (Linux command)
Find files and directories by name, type, size, age or permissions, and act on them with -exec, -delete or xargs.
Bash 5
Syntax
find PATH [TESTS] [ACTIONS]
Parameters
| Parameter | Description |
|---|---|
-name '*.log' |
Match names (quote the pattern). |
-type f|d |
Files or directories. |
-mtime -7 / +30 |
Modified within / older than days. |
-size +10M |
Larger than 10 MB. |
-exec CMD {} + |
Run a command on the results. |
-print0 |
NUL-separated output for xargs -0. |
Examples
mkdir -p a/b; touch a/x.log a/b/y.log a/z.txt
find a -name '*.log' | sort
find a -type d | sort
Output
a/b/y.log a/x.log a a/b
Run this on your computer — see “Get Started” for setup.
touch -d 2026-01-01 old.tmp; touch new.tmp
find . -name '*.tmp' -mtime +7 -print -delete
ls *.tmp
Output
./old.tmp new.tmp
Run this on your computer — see “Get Started” for setup.
Related
xargs· Build and run commands from input lines, in batches or in parallel; pair with find -print0 and xargs -0 for safe file names.- Bash find and xargs · tutorial