Spread knowledge in your company: Print out 1-pagers and display them at the water cooler
Navigation Menu+

The find command in examples

Posted on Feb 25, 2015 by in Development, DevOps & SysAdmins | 3 comments

Corinna – a Mac user – likes working on the terminal but she never managed to find anything with it. She used to switch to OS X’s Finder for searching. Not anymore! She finally sat down to figure out find and has assembled her favorite examples in this cheat sheet like 1-pager:


Did you know there are compilations of our 1-pagers? About Agile & Scrum, Facilitation and for Product Owners


Content of the 1-pager:


look for “needle.txt” within the current directory & its subdirectories
find . -name “needle.txt”
ignore case, find “Needle” & “needle”
find . -iname “needle”
name contains “needle”; list only matching files
find . -type f -name “*needle*”
search everywhere; list only matching directories
find / -type d -name “needle”
additionally ignore all errors, such as “Permission denied”
find / 2>/dev/null -type d -name “needle”


check all .txt files whether they contain “needle”
find . -type f -iname “.txt” -print | xargs grep “needle”
same as above, but now it also works with filenames that contain spaces
find . -type f -iname “*.txt*” -print0 | xargs -0 grep “needle”
find all empty files in /tmp
find /tmp -type f -empty
remove all these empty files
find /tmp -type f -empty -print | xargs rm -f


files bigger than 50MB but smaller than 100MB
find / -type f -size +50M -size -100M
created during the last 50 days
find / -ctime -50
modified more than 90 minutes ago
find / -mmin +90
accessed during the last 24 hours but
not within the last hour
find / -atime -1 -amin +60


find all executable files
find / -perm /a=x
find files that don’t have 644 permissions
find / -type f ! -perm 644
find files with 777 permissions a nd change them to 755
find / -type f -perm 0777 -print -exec chmod 755 {} \;
find all PDFs owned by user “seamstress” (-group exists, too)
find / -user seamstress -iname “*.pdf”


  1. Awesome breakdown of find.

    • Thanks!

  2. FIND is more powerfull tool but in this examples is show the most uses command, good job

Submit a Comment

Your email address will not be published. Required fields are marked *