Friday, 1 January 2010

Find Tips

Remove files older than certain days (using find/mtime)
find -name "" -mtime +N -exec rm -r {} \;

Eg : find /var/log/ -name "*.log" -mtime +5 -exec rm -r {} \;
This will remove the *.log files older than 5 days in directory /var/log/

Find with file type

directories : find / -type d -print0
files: find / -type f -print0

No comments:

Post a Comment