This is a quick reference list of cheatsheet for linux find command, contains common options and examples.
$ find [path...] [options] [expression]
Wildcard
$ find . -name "*.txt"
$ find . -name "2020*.csv"
$ find . -name "json_*"
Regex reference (quickref.me) Find cheatsheet (gist.github.com)
-type β find . -type d β Find only directories
-name β find . -type f -name "*.txt" β Find file by name
-iname β find . -type f -iname "hello" β Find file by name (case-insensitive)
-size β find . -size +1G β Find files larger than 1G
-user β find . -type d -user jack β Find jack's file
-regex β find /var -regex '.*/tmp/.*[0-9]*.file' β Using Regex with find. See regex
-maxdepth β find . -maxdepth 1 -name "a.txt" β In the current directory and subdirectories
-mindepth β find / -mindepth 3 -maxdepth 5 -name pass β Between sub-directory level 2 and 4
-type d β Directory
-type f β File
-type l β Symbolic link
-type b β Buffered block
-type c β Unbuffered character
-type p β Named pipe
-type s β Socket
-size b β 512-byte blocks (default)
-size c β Bytes
-size k β Kilobytes
-size M β Megabytes
-size G β Gigabytes
-size T β Terabytes (only BSD)
-size P β Petabytes (only BSD)
Find all bigger than 10MB files
$ find / -size +10M
Find all smaller than 10MB files
$ find / -size -10M
Find all files that are exactly 10M
$ find / -size 10M
Find Size between 100MB and 1GB
$ find / -size +100M -size -1G
The + and - prefixes signify greater than and less than, as usual.
Find files using name in current directory
$ find . -name tecmint.txt
Find files under home directory
$ find /home -name tecmint.txt
Find files using name and ignoring case
$ find /home -iname tecmint.txt
Find directories using name
$ find / -type d -name tecmint
Find php files using name
$ find . -type f -name tecmint.php
Find all php files in directory
$ find . -type f -name "*.php"
Find the files whose permissions are 777.
$ find . -type f -perm 0777 -print
Find the files without permission 777.
$ find / -type f ! -perm 777
Find SUID set files.
$ find / -perm /u=s
Find SGID set files.
$ find / -perm /g=s
Find Read Only files.
$ find / -perm /u=r
Find Executable files.
$ find / -perm /a=x
Find single file based on user
$ find / -user root -name tecmint.txt
Find all files based on user
$ find /home -user tecmint
Find all files based on group
$ find /home -group developer
Find particular files of user
$ find /home -user tecmint -iname "*.txt"
$ find . -type f \( -name "*.sh" -o -name "*.txt" \)
Find files with .sh and .txt extensions
$ find /opt /usr /var -name foo.scala -type f
Find files with multiple dirs
$ find . -type d -empty
Delete all empty files in a directory
$ find . -type f -empty -delete
atime β access time (last time file opened)
mtime β modified time (last time file contents was modified)
ctime β changed time (last time file inode was changed)
-mtime +0 β Modified greater than 24 hours ago
-mtime 0 β Modified between now and 1 day ago
-mtime -1 β Modified less than 1 day ago (same as -mtime 0)
-mtime 1 β Modified between 24 and 48 hours ago
-mtime +1 β Modified more than 48 hours ago
-mtime +1w β Last modified more than 1 week ago
-atime 0 β Last accessed between now and 24 hours ago
-atime +0 β Accessed more than 24 hours ago
-atime 1 β Accessed between 24 and 48 hours ago
-atime +1 β Accessed more than 48 hours ago
-atime -1 β Accessed less than 24 hours ago (same as -atime 0)
-ctime -6h30m β File status changed within the last 6 hours and 30 minutes
Find last 50 days modified files
$ find / -mtime 50
find last 50 days accessed files
$ find / -atime 50
find last 50-100 days modified files
$ find / -mtime +50 βmtime -100
find changed files in last 1 hour
$ find / -cmin -60
find modified files in last 1 hour
$ find / -mmin -60
find accessed files in last 1 hour
$ find / -amin -60
Find and remove multiple files
$ find . -type f -name "*.mp3" -exec rm -f {} \;
Find and remove single file
$ find . -type f -name "tecmint.txt" -exec rm -f {} \;
Find and delete 100mb files
$ find / -type f -size +100m -exec rm -f {} \;
Find specific files and delete
$ find / -type f -name *.mp3 -size +10m -exec rm {} \;
Find all files and modify the content const to let
$ find ./ -type f -exec sed -i 's/const/let/g' {} \;
Find readable and writable files and modify the content old to new
$ find ./ -type f -readable -writable -exec sed -i "s/old/new/g" {} \;
See also: sed cheatsheet
Find and suffix (added .bak)
$ find . -type f -name 'file*' -exec mv {} {}.bak\;
Find and rename extension (.html => .gohtml)
$ find ./ -depth -name "*.html" -exec sh -c 'mv "$1" "${1%.html}.gohtml"' _ {} \;
$ find . -name '*.mp3' -exec mv {} /tmp/music \;
Find and move it to a specific directory (/tmp/music)
$ find . -name '*2020*.xml' -exec cp -r "{}" /tmp/backup \;
Find matching files and copy to a specific directory (/tmp/backup)
Merge all csv files in the download directory into merged.csv
$ find download -type f -iname '*.csv' | xargs cat > merged.csv
Merge all sorted csv files in the download directory into merged.csv
$ find download -type f -iname '*.csv' | sort | xargs cat > merged.csv
Find and sort in ascending
$ find . -type f | sort
find and sort descending
$ find . -type f | sort -r
Find files and set permissions to 644.
$ find / -type f -perm 0777 -print -exec chmod 644 {} \;
Find directories and set permissions to 755.
$ find / -type d -perm 777 -print -exec chmod 755 {} \;
Find all .java files and compress it into java.tar
$ find . -type f -name "*.java" | xargs tar cvf java.tar
Find all .csv files and compress it into quickref.zip
$ find . -type f -name "*.csv" | xargs zip quickref.zip