Pages

Monday, June 18, 2012

TO FIND & REMOVE OLD and BIG SIZE FILES IN LINUX
===============================================

To find the files which are xx days older:

Syntax: find . -mtime +<no.of days> -exec ls -ltr {} \;

example: find . -mtime +30 -exec ls -ltr {} \;


To remove the files that are xx days older:

Syntax: find . -mtime +<no.of days> -exec rm -rf  {} \;

example: find . -mtime +30 -exec rm -rf  {} \;


To find the files which are XXk of SIZE:

Syntax: find . -size +<size of the file in kbytes> -type f -exec ls -ltr {} \;

example: find . -size +5120k -type f -exec ls -ltr {} \;  == exampls for 5MB size files

To remove the files which are more than XXk size:

Syntax: find . -size +<size of the file in kbytes> -type f -exec rm -rf {} \;

example: find . -size +5120k -type f -exec rm -rf {} \;

3 comments: