Searching and File Operations in linux

TOP 10 largest file
# find /var -type f -ls | sort -k 7 -r -n | head -10

FIND FILES MORE THAN 5Gb
# find /var/log/ -type f -size +5120M -exec ls -lh {} \;

Find all temp files older than a month and delete:
# find /usr/home/admin/Maildir/new -mtime +30-type f | xargs /bin/rm -f

# find /usr/local/apache -mtime +30-type f | xargs /bin/rm -f

# find /usr/home/admin/Maildir/new -mtime +30-type f | xargs /bin/rm -f

# find /usr/local/apache* -type f -mtime +30 -exec rm '{}' '+'

# find /home/ksucre/Maildir/new/ -mtime +50-type f | xargs /bin/rm -f

# find /usr -size +5000M

To find files older than, for example, 10 days.
# find /home/user1/Maildir/new -mtime +10

Find files older than, say, 30 minutes:
# find /tmp -mmin +30

Remove files older than x days like this
# find /path/* -mtime +x -exec rm {} \;

No comments: