×

Welcome to TagMyCode

Please login or create account to add a snippet.
0
0
 
0
Language: Bash
Posted by: Roman Ignatov
Added: Nov 30, 2016 11:13 AM
Views: 16
  1. # Delete Files Older Than x Days on Linux
  2.  
  3. find /path/to/files* -mtime +5 -exec rm {} \;
  4.  
  5.  
  6. # rm files older than 3 days
  7.  
  8. find /path/to/folder -mtime +3 -exec rm -f {} \;
  9.  
  10. # Move Files Older Than X Days To Another Directory
  11.  
  12. find . -type f -mtime 7 | xargs -I % mv % ../old_files/
  13.  
  14. find . -type f -exec grep -H 'Complete.' {} \; |awk -F: '{ print $1; }' | xargs  -t  -I {} mv {} success/
  15.  
  16. # delete files by "find" mask of file name
  17.  
  18. find . -name "*.css" -type f -delete
  19.  
  20.