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

Create a free account to save this page, take notes and track your progress. Sign in

Syntax

find PATH [TESTS] [ACTIONS]

Parameters

ParameterDescription
-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

By name and type
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.

Delete files older than 7 days
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.

Was this page helpful?