Remove Old Files

You can use “find” command with “-exec” parameter to remove old files in UNIX system.

$ find <Directory> -maxdepth 1 -mtime +<Days> -exec rm -f {} \;

Please see the following for the meanings of each parameter.

<Directory> Specify a directory where the target files are located.
-maxdepth 1 Search files only in the given directory by setting “1”. Ignore the child directories.
-mtime +<Days>

Search files modified more than <Days> days ago.


-exec rm -f {} \; Execute “rm” command on the found files.


Leave a Reply

Required fields are marked *.

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