Finding files with find

Last modified on July 24, 2026 • 2 min read • 313 words
Finding files with the find command is actually more difficult than it should be.
Finding files with the find command is actually more difficult than it should be. This finds and lists the largest files (more than 200 MB) on the whole file system:find / -type f -size +200000k -exec ls -lh {} \; | awk '{ print $9 ": " $5 }'The same, but simpler syntax:find / -size +200M -lsThis finds the most recently changed files under the current directory:find . -type f -printf '%TY-%Tm-%Td %TT %p\n' | sortAnd this command pipes the results of the find command into another command. First find looks for Quicktime movies (based on the file extension .mov) and then ffmpeg converts them into avi files.find . -name '*.mov' -exec sh -c 'ffmpeg -i "$0" -sameq "${0%%.mov}.avi"' {} \;This commands finds and lists all filenames that contain the string ‘bitcoin’:find . -name '*bitcoin*' -lsAnd this command finds Quicktime movies and deletes them:find . -name '*.mov' -exec sh -c 'rm "$0"' {} \;And this finds files that have been modified (created or updated) during the last 2 minutes:find . -cmin 2This finds crap which you copied over from a Macintosh and which you don’t need under Linux:find . -name '*.DS_Store' -type f -deleteSimilar story here:find . -name '._*' -type f -deleteWhen being in the root directory, this should find all files with the name ‘syncthing’:find . -name 'syncthing' -lsAnd this finds all files larger than 200MB in the /home directory:find /home -size +200M -lsFind recursively all files that end in .gz and count them:find . -name '*.gz' | wc -lFind recursively all files that do NOT end in .gz and count them:find . -not -name '*.gz' | wc -lWhen you want to search recursively through the content of text files, you need to use the grep command:grep -rnw '/path/to/target-directory' -e 'pattern'When you search for PDF files modified in October 2024:sudo find / -type f -name "*.pdf" -newermt "2024-10-01" ! -newermt "2024-11-01" 2>/dev/null