Commands · Command

CommandLinuxmacOS

find

find [path] [expression]

Recursively searches a directory tree for files or directories matching criteria like name, size, or modification time.

// FLAGS

-namematch by filename pattern
-typef for file, d for directory
-mtimematch by modification age in days
-execrun a command on each match
-sizematch by file size

// EXAMPLE

find /home -name "*.log" -mtime +30 — lists every .log file under /home older than 30 days.

// GOTCHA

-exec requires a trailing \; (or + to batch) to terminate the command — forgetting it is a very common syntax error.

// RELATED COMMANDS