Tools

find

Locate files by name, type, size, owner, and date — then act on them.

Syntax

find <path> <conditions> <actions>General form
find . -name "*.txt"Find .txt files in cwd
find / -name configSearch entire filesystem

Name & type

-name "*.c"Match by filename pattern
-iname "*.C"Case-insensitive name match
-type fRegular files
-type dDirectories
-type lSymbolic links
-regex PATTERNFull path regex

Size & time

-size +10MLarger than 10 MiB
-size -128cSmaller than 128 bytes
-newer file.txtNewer than reference file
-mtime -1Modified in last 24 hours
-mtime +7Modified more than 7 days ago
-atime 0Accessed within last 24 hours

Ownership & logic

-user usernameOwned by user
-nouserNo valid owner
\! -name "*.c"NOT operator
\( expr1 -or expr2 \)OR grouping
-depth 2At least 3 levels deep

Actions

-printPrint matching paths (default)
-deleteDelete matched files
-exec cmd {} \;Run command on each match

Examples

find . -name '*.jpg' -exec rm {} \;Delete all JPEGs
find . -type f -mtime +30Files untouched 30+ days
find . -size +100MFiles larger than 100 MB
find . -name '*.ts' -not -path '*/node_modules/*'Exclude node_modules