Skip to content

Powerful Find Command Cheatsheet

Explore the versatility of the find command in Unix/Linux systems with this comprehensive cheatsheet. Discover various find commands to search for files based on modification time, access time, size, type, and more. Enhance your file searching skills and streamline your workflow efficiently.


Search for various urls in files

find . -type f -print0 | xargs -0 -P $(nproc) -I {} bash -c '
for file in "$@"; do
  strings "$file" | rg --pcre2 -o -i -e "(http|https|ftp|ftps|smtp|imap)://[a-zA-Z0-9./?=_-]+(?![a-zA-Z0-9./?=_-])" |
  while read -r url; do
    echo -e "Filename: $file \033[1;32m$url\033[0m"
  done
done' bash {}

Delete folders when it replies directory is not empty

find . -name ".git" -type d -exec rm -rf {} +

Find files modified within the last 1 day

find / -mtime -1

Find files modified within the last 2 days

find / -mtime -2

Find files modified within the last 3 days

find / -mtime -3

Find files modified within the last 4 days

find / -mtime -4

Find files modified within the last 5 days

find / -mtime -5

Find files modified within the last 6 days

find / -mtime -6

Find files modified within the last 1 week

find / -mtime -7

Find files modified within the last 2 weeks

find / -mtime -14

Find files modified within the last 3 weeks

find / -mtime -21

Find files modified within the last 1 hour

find / -mmin -60

Find files modified within the last 30 minutes

find / -mmin -30

Find files modified within the last 10 minutes

find / -mmin -10

Find files accessed within the last 1 day

find / -amin -1440

Find files accessed within the last 2 days

find / -amin -2880

Find files accessed within the last 3 days

find / -amin -4320

Find files accessed within the last 1 hour

find / -amin -60

Find files accessed within the last 30 minutes

find / -amin -30

Find files accessed within the last 10 minutes

find / -amin -10

Find files that had their status changed within the last 1 day

find / -cmin -1440

Find files that had their status changed within the last 2 days

find / -cmin -2880

Find files that had their status changed within the last 3 days

find / -cmin -4320

Search for Files Only

find -type f

Search for Folders Only

find -type d
find -type l

Search 3 Levels Deep

find -depth 2

Search for Files via Regex

find -regex PATTERN

Exactly 8 512-bit Blocks

find -size 8

Smaller Than 128 Bytes

find -size -128c

Exactly 1440KiB

find -size 1440k

Larger Than 10MiB

find -size +10M

Larger Than 2GiB

find -size +2G

Search for All Files Larger Than 500MB

find / -type f -size +500M

Search for All Executable Files

for i in $(find -type f); do [ -x "$i" ] && echo "$i is executable"; done

Search for Foo Text Inside All Files in Current Folder Using Parallel

find . -type f | parallel -k -j150% -n 1000 -m grep -H -n 'foo' {}
find -L /path/to/check -type l -delete
find -L / -samefile /path/to/file -exec ls -ld {} +

Find the Most Recently Changed Files (Recursively)

find . -type f -printf '%TY-%Tm-%Td %TT %p\n' | sort

Remove 'Fucked' Dirnames from Microsoft Windows and Apple

ls -li | find . -inum 4063242 -delete

Find All Gz Files and Extract Them

find . -type f -iname "*.gz" -print0 | xargs -0 -I {} atool -x "{}" -delete

Last Accessed Between Now and 24 Hours Ago

find -atime 0

Accessed More Than 24 Hours Ago

find -atime +0

Find With Invert Match - E.g., Find Every File That Is Not Mp3

find . -name '*' -type f -not -iname '*.mp3'

Find Files/Directories Modified Within a Given Period

find . -type d -newermt "2019-01-01" ! -newermt "2019-02-01" -exec ls -ld {} \;

Store the Output of Find in an Array

mapfile -d $'\0' arr < <(find /path/to -print0)

Find All Log Files Modified 24 Hours Ago and Zip Them

find . -type f -mtime +1 -name "*.log" -exec zip -m {}.zip {} \; >/dev/null

Search for AT Atention commands

find . -type f -name "*.apk" -print0 | xargs -0 strings | grep -E 'AT[\+\*][A-Z]{2,10}([^A-Z]|$)'

Search for a pattern inside multiple tar.gz archives

find . -name '*.tar.gz' -print0 | xargs -0 -P $(nproc --all) -I {} tar -tzf {} | grep 'pattern'