Difference between revisions of "Find"
From DevOps Notebook
Line 1: | Line 1: | ||
− | == Find largest files in given location == | + | === Find largest files in given location === |
<pre> | <pre> | ||
− | find /home/ | + | $ find /home/devops/Downloads/ -type f -exec du -Sh {} + | sort -rh | head -n 5 |
</pre> | </pre> | ||
− | == Delete files older then X hours == | + | === Delete files older then X hours === |
<pre> | <pre> | ||
− | find | + | $ find /backup -name *.log -type f -mmin +360 -delete |
+ | </pre> | ||
+ | === Delete files older then 30 days === | ||
+ | <pre> | ||
+ | $ find /backup -type f -mtime +30 -exec rm -f {} \; | ||
</pre> | </pre> |
Revision as of 08:39, 17 April 2020
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 {} \;