Pages

Saturday, January 15, 2011

Using Find to Delete Files

  1.  All files older than 5 days 
    •  find /path/to/files* -mtime +5 -exec rm {} \; 
  2.  Log files (-type f) older than six months in sub directories 
    •  find /path/to/files/ -mtime +180 -type f -maxdepth 2 -exec rm -rf {} \; 
    •  -type f 
      • log files 
    •  -mtype +180 
      • older than six months 
    •  -maxdepth 2 
      • to a directory level of 2

No comments: