Find Command examples

Find Command is one of the most important and frequently used command utility in Unix like operating systems. It is used to search and locate the list of files and directories based on conditions you specify for files that match the arguments.

Find all file whose name is justgeek.txt

# find -name justgeek.txt

Find all files whose name starts with justgeek

# find -name justgeek.*

Find all Directories whose name is justgeek

# find -type d -name justgeek

NOTE: you can use iname instead of name if you do want to match exact case.

Find all Directories whose name is justgeek in /home

# find /home -type d -name justgeek

Find all html file in /home folder

# find /home -type f -iname "*.html"

Find all files whose name ends with .tmp in /home folder and delete them.

# find /home -type f "*.tmp" -exec rm -fv {} \;

Find Empty files

# find /tmp -type f -empty

Find empty directories

# find /tmp -type d -empty

Find all files whose size is more than 500 MB

# find /home/justgeek -type f -size +500M

Find particular files types with size more than 100 MB and delete it.

# find / -type f -name message.logs -size +100M -exec rm -fv {} \;

Find files older than 24 hours and delete them

# find /tmp/logs -type f -mmin +1440 -exec rm -fv {} \;

Find all files older then 60 Mins and move them to a different folder

# find /tmp/logs*tar -mmin +60 -exec mv {} /home/backup \;