Re: Testing file age in seconds
From: Netocrat (netocrat_at_dodo.com.au)
Date: Mon, 13 Jun 2005 10:37:42 GMT
> I'd like to test whether a file is older than a specified age in seconds
> from within a bash shell script. It would be acceptable to use another
> utility such as find or awk but I wouldn't want to rely on something such
> as perl or python being present.
I've found the stat command which doesn't seem to be standard and portable
but is better than a self-made executable. My code is:
FILETIME=`stat -c %Y $PATHTOFILE`
if [ $NOW-$FILETIME -gt $AGE ]
# File is older
# File is not older
Let me know of anything more portable.