OSUnix

Removing Older files in Unix

Support analysts know it well 😉

We mostly have the requirement to remove the older files from the directory.

Lets look at the quickest solution to achieve the task of Removing Older files

Solution :

find . -ctime +20 -exec ls -ltr {} \; 

Explanation :

  • find . : Find files in current directory
  • find . -ctime +20 : Find files in current directory which are created 20 days before
  • find . -ctime +20 -exec : Find files in current directory which are created 20 days before & execute the command on it
  • find . -ctime +20 -exec ls -ltr {} \; : Find files in current directory which are created 20 days before & execute the long listing comand on it
About author

Love coding, crazy about logic, like solution architecting and solving problems. Thirsty for knowledge, challenges & most importantly innovation. One of the passionate brain behind SpryOX

Leave a Reply

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