Find

From DevOps Notebook
Revision as of 08:39, 17 April 2020 by MilosZ (talk | contribs)

Find largest files in given location

$ find /home/devops/Downloads/ -type f -exec du -Sh {} + | sort -rh | head -n 5

Delete files older then X hours

$ find /backup -name *.log -type f -mmin +360 -delete

Delete files older then 30 days

$ find /backup -type f -mtime +30 -exec rm -f {} \;