find tool patterns


These are few Linux find patterns I find useful in a daily work.
The ones below were of great help when I had to clean Esafe that had more than 100,000 files in the spool ! So usual shell wild-card expansion didn't work (try to do ls in a folder with 130000 files ;). I sorted and then removed files by date - files created last 24 hours per remove.

        find . -mtime 0 -exec rm -f {} \;  
        find . -mtime 0 # find files created/modified within the past 24 hours  
        find . -mtime -1 # find files created/modified within the past 0 - 24 hours  
        find . -mtime 1 # find files modified between 24 and 48 hours ago  
        find . -mtime +1 # find files modified more than 48 hours ago  
        find . -mmin +3 -mmin -10 # find files modifed between 4 and 9 minutes 
        find . -type f -size +30M -ls  # find files larger than 30 Mb and list them

Default is  logical AND between clauses
NB the -regexp switch to the find looks for a complete match !
Finding by permission pattern and then removing:
- Find files that have at LEAST following permissions set an ddelte them
find . -type f -perm -0750 -exec rm -f {} \;
- Find files with ANY of the permissions set and delete them:
find . -type f -perm +0750 -exec rm -f {} \;
- Find files with pattern EXACTLY matching and delete them :
find . -type f -perm 0750 -exec rm -f {} \;
- Find by UID filetype and size and list them:
find . -type f -uid 0 -size +2k -exec ls -l {} \;
modifiers to size switch: b w k c

Follow me on https://www.linkedin.com/in/yurislobodyanyuk/ not to miss what I publish on Linkedin, Github, blog, and more.