find

Search for files in a directory hierarchy. It can find files based on name, size, modification time, type, and permissions.

Synopsis

find [path] [expression]

Core Options

-name pattern

Base of file name (the path with the leading directories removed) matches pattern.

-type c

File is of type c: f (regular file), d (directory), l (symbolic link).

-mtime n

File's data was last modified n*24 hours ago.

-size n

File uses n units of space.

-exec command ;

Execute command; true if 0 status is returned.

Usage Examples

Find by Name

Find all files named 'config.json' in the current directory and subdirectories.

find . -name 'config.json'

Find Files by Extension

Find all Python files.

find . -type f -name '*.py'

Find Large Files

Find files larger than 100MB.

find / -size +100M

Find Recently Modified Files

Find files modified in the last 7 days.

find . -mtime -7

Find and Delete

Find all .tmp files and delete them.

find . -name '*.tmp' -delete

Find and Execute

Find all .png files and change their permissions to 644.

find . -name '*.png' -exec chmod 644 {} \;
Built for builders.