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

Vikram Pawar

Vikram Pawar

Coder by passion..... Thirsty for knowledge, challenges & most importantly innovation. Working with BNP Paribas

Leave a Reply

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