You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Find all files that were modified between 50 to 100 days ago:
find / -mtime +50 –mtime -100
Find files changed in last N minutes.
Find files modified within the last 1 hour:
find /home/bob -cmin -60
Files modified in last hour
To find all the files which are modified in last 1 hour:
find / -mmin -60
Find Accessed Files in Last 1 Hour
find / -amin -60
Find files of given size
Search files and directories based on size. To find all 50MB files, use:
find / -size 50M
Find files in a size range
To find all the files which are greater than 50MB and less than 100MB.
find / -size +50M -size -100M
Find largest and smallest files
The following command will display the 5 largest file in the
current directory and its subdirectory. This may take a while to execute
depending on the total number of files the command has to process:
find . -type f -exec ls -s {} \; | sort -n -r | head -5
Similary when sorted in ascending order, it would show the smallest files first:
find . -type f -exec ls -s {} \; | sort -n | head -5
Find empty files and directories
Find empty directories and files:
find /tmp -type f -empty
List out the found files
find . -exec ls -ld {} \;
Delete all matching files or directories
find /tmp -type f -name "\*.txt" -exec rm -f {} \;
Lets take another example where we want to delete files larger than 100MB:
find /home/bob/dir -type f -name \*.log -size +10M -exec rm -f {} \;