Chris Norman wrote:
Hi people,
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?
Cheers,
Chris Norman
<!-- chris.norman4@xxxxxxxxxxxx -->
Sounds like a job for the find command. This
find . -mtime +30 -type f -exec rm {} \;
will delete anthing over 30 or more days old in the current directory
and any of its subdirectories. The '.' is the current directory but you
can use any valid path. The + before the 30 is needed otherwise only
files modified exactly 30 days ago would be deleted. The -type f means
only files (no directories).
Do a find . mtime +30 -type f -print to just get a list of the found files.
Hope this helps,
Dan.
--
fedora-list mailing list
fedora-list@xxxxxxxxxx
To unsubscribe: https://www.redhat.com/mailman/listinfo/fedora-list