Locate files by name, size or age — then act on them. Tap any command to copy it.
find . -name '*.txt'Find files by name patternfind . -iname '*.txt'Case-insensitive name searchfind . -type fFind files only (not directories)find . -type dFind directories onlyfind . -name '*.log' -type fCombine name and typefind . -size +100MFiles larger than 100 MBfind . -size -1kFiles smaller than 1 KBfind . -mtime -7Modified in the last 7 daysfind . -mtime +30Not modified in over 30 daysfind . -maxdepth 1 -name '*.sh'Limit the search to one level deepfind . -emptyFind empty files and directoriesfind . -name '*.tmp' -deleteDelete every matching filefind . -name '*.sh' -exec chmod +x {} \;Run a command once per resultfind . -name '*.log' -exec rm {} +Run once with all results batchedfind . -type f | xargs grep 'pattern'Pipe results into another commandfind . -perm 644Find files with specific permissionsfind . -user aliceFind files owned by a userfind . -type f -name '*.jpg' | wc -lCount files matching a patternfind walks a directory tree and tests every file against the conditions you give it. The first argument is where to start (. for the current directory), and everything after is a filter. -name '*.txt' matches by filename (use -iname to ignore case), and -type f or -type d restricts to files or directories. Conditions stack left to right, so find . -type f -name '*.log' reads naturally as "files, named *.log, under here."
Two of find's most useful filters are size and time. -size +100M finds files bigger than 100 megabytes (great for tracking down what's filling a disk), and -mtime -7 finds files modified in the last seven days (+30 flips it to "older than 30 days"). The + and - prefixes mean "more than" and "less than", a convention that trips people up until it clicks. -maxdepth stops find from descending too far, which keeps big searches fast.
Finding files is only half the job — usually you want to do something with them. -delete removes matches (always preview with -print first), while -exec runs any command on each result, with {} standing in for the filename. The terminator matters: \; runs the command once per file, and + batches many files into a single call for speed. For more complex pipelines, piping find's output into xargs is the classic combo. Pair find with grep to search inside the files you locate.