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 patternBase of file name (the path with the leading directories removed) matches pattern.
-type cFile is of type c: f (regular file), d (directory), l (symbolic link).
-mtime nFile's data was last modified n*24 hours ago.
-size nFile 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 +100MFind Recently Modified Files
Find files modified in the last 7 days.
find . -mtime -7Find and Delete
Find all .tmp files and delete them.
find . -name '*.tmp' -deleteFind and Execute
Find all .png files and change their permissions to 644.
find . -name '*.png' -exec chmod 644 {} \;Built for builders.