Date scripting

Les Mikesell lesmikesell at gmail.com
Fri Mar 24 04:21:16 UTC 2006


On Thu, 2006-03-23 at 12:05, Chris Norman wrote:
> I need to check files to see how old they are.
> 
> How can I do this from within a backup script?
> 
> I need to see if they are over a month old, and if so delete them. How do I 
> get they're last modified stamp please?


cd /path/to/start || exit 
find  . -type f -ctime +31 
would give you a list of files more than 31 days old.

find . -type f -ctime +31 -print0 |xargs -0 rm -f
would delete them - but be sure you know what you are
doing before you execute that... And be sure you
quit if you can't cd to the right place instead of
deleting in the wrong location.

-- 
  Les Mikesell
   lesmikesell at gmail.com






More information about the fedora-list mailing list