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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]



> 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.

You want to get the modification time of the file most likely.  This 
can be done using the "stat" command.  This will return the "Time of 
last modification as seconds since Epoch" of the given file:

   stat --format="%Y" /path/to/file

Just compare this number to the current time (in seconds since Epoch) 
and you can determine the age of a file.

Alfred


[Index of Archives]     [CentOS]     [CentOS Announce]     [CentOS Development]     [CentOS ARM Devel]     [CentOS Docs]     [CentOS Virtualization]     [Carrier Grade Linux]     [Linux Media]     [Asterisk]     [DCCP]     [Netdev]     [Xorg]     [Linux USB]
  Powered by Linux