[CentOS] how to tell if a file is older than 30 days?

Robert kerplop at sbcglobal.net
Thu Sep 15 16:39:39 UTC 2005


Jerry Geis wrote:

> I am trying to find out how to tell if a given file is 30 days or older.
> How is that type of thing done in shell scripts.
>
> Thanks,
>
> Jerry

As with all things *nix, there is more than one way to do the job. You 
might start with this idea -- or not.  If you wanted to list all files 
in the current directory over 29 days old (you said "30 or older) this 
would do it:

$ find . -ctime +29   -print
   --OR-- those older than 29 days in your home directory
$ find ~ -ctime +29 -print  
   --OR-- to discover older rpms in the yum cache
$ find /var/cache/yum -ctime +29 -print | grep .rpm

Man find is your friend.  Don't be overwhelmed by its many options; 
start simple and build up to your goal.

>
>------------------------------------------------------------------------
>
>_______________________________________________
>CentOS mailing list
>CentOS at centos.org
>http://lists.centos.org/mailman/listinfo/centos
>  
>






More information about the CentOS mailing list