24/04/15

Find Quick Reference

Basic find usage

Find files with name (case insensitive)
# find . -iname 'myfile' 
Find files with name (case sensitive)
# find . -name 'MyFiLe' 
Find empty files
# find . -empty
Find top 10 big files
# find . -type f -exec ls -s {} \; | sort -n  -r | head -10
Find top 10 small files
# find . -type f -exec ls -s {} \; | sort -n | head -10
Find files bigger than size
# find . -size +100M
Find files and print size and name
# find . -name '*.pdf' -printf '%s  %p\n'



Advanced find usage

Delete files older than 30 days.
!!!Attention!!! -delete options delete all files and directory recursively where the command will be executed!
# find /db_backups/ -mtime +30 -delete
Create a tar archive from find output
# find . -type f -print0 | tar -czvf backup.tar.gz --null -T -

Nessun commento:

Posta un commento