find by name
find /directory -name “filename.ext”
find /directory -name filename.*
find /directory -name *.php
ignore case
find /directory -iname “filename.ext”
invert results (list files that don’t end with .php)
find /home/test ! -name “*.php”
search only 1 directory deep
find /home/test -maxdepth 2 -name “*.php”
only 2 directories deep
find /home/test -maxdepth 3 -name “*.php”
Find all directories
# find . -type d
Find only the normal files
# find . -type f
Find all the hidden files
# find . -type f -name “.*”
Find all the hidden directories
# find -type d -name “.*”
Find files bigger than the given size
# find ~ -size +100M
Find files smaller than the given size
# find ~ -size -100M
Find files that matches the exact given size
# find ~ -size 100M
Accessed files
Find based on minutes (60 minutes)
find /home -amin -60
Long list the files which are accessed within the last 1 hour.
find /home -amin -60 -exec ls -l {} \;
Find based on day(s) (24 hours)
find /home -atime -1
Long list the files which are accessed within the last 1 day.
find /home -atime -1 -exec ls -l {} \;
Modified files
Find based on minutes (60 minutes)
find /home -mmin -60
Long list the files which are accessed within the last 1 hour.
find /home -mmin -60 -exec ls -l {} \;
Find based on day(s) (24 hours)
find /home -mtime -1
Long list the files which are accessed within the last 1 day.
find /home -mtime -1 -exec ls -l {} \;
hide errors (Permission denied)
find -name “*.txt” 2>>/dev/null