configuration-guide.com

simple configuration guide for your computer related tasks

Menu
Menu

linux how to remove files older than certain days

Posted on April 4, 2012 by voidzzz

this very easy linux command can be use to remove files older than certain days. Its very useful when you’re doing clean-up of old files.

Step by step :

  1. Switch to the directory where you want to remove the files
  2. issue the following command : find -mtime +60 -exec rm {} \;

Explanation :

  • find : command to find all files
  • -mtime +60 : switch to find files older than 60 days
  • -exec rm {} \; : remove all the files that match the above switch

alternative : find /path/to/folder/* -mtime +60 -exec rm{} \;

the alternative not recommended for long path as you will have “Argument to long” error.

Hope it helps …

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

User Control Panel

  • Log in
  • Entries RSS
  • Comments RSS
  • WordPress.org

Configuration Category

©2022 configuration-guide.com | Built using WordPress and Responsive Blogily theme by Superb