Date scripting

Richard England rengland at europa.com
Fri Mar 24 04:53:30 UTC 2006


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 at ntlworld.com -->

Take a look at the  stat command.  Perhaps something along the lines of

stat -c  '%n %z'  <file name>

which would give you something  like:

<file name> 2006-03-18 16:26:17.000000000 -0800


Or perhaps just use

ls -ltr

which will give you a sorted list of files in the current directory with 
the oldest first.


--R
------------------------------------------------------------------------
/I got Freedom,...I got freedom in my code (FC3/FC4)/
Registered Unix <http://counter.li.org> user #409453




More information about the fedora-list mailing list