How to list or remove file which is older then N days

If you’r trying  to  get  list  of  file or directory which  is  older then “N” days you should  check this  script. There  is an easy way  to get  this  information with  find  command. Find  command  mtime  option will show us  the files  which  older then “N” days. Also script will show us file’s  last modified date.

Usage:

To Define Action = “-a list|remove”
To Define Days = “-d NumberOfDays”
To Define File or Directory search = ” -t f|d”
To Define Path = “-p FilePath”‘

Example-1:This  example will list files  which  are  older then 30  days.

#./NdaysOlder.sh  -a  list  -t f -p  /tmp/  -d 30

Example-2:This  example will list files  which  are  older then 30  days.

#./NdaysOlder.sh  -a  list  -t d -p  /tmp/  -d 10

 

Follow me

Abdurrahim

I'm a System Engineer with extensive experience and administration skills and works for Interbank Card Center Of Turkey.I provide hardware and software support for the following Unix/Linux and Windows platforms.(Oracle Solaris,HP-UX, Linux, IBM-AIX, Windows Servers)
Follow me
facebooktwittergoogle_pluslinkedinby feather

0