Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 27 Dec 2006 16:50:15 +0000
From:      "N.J. Mann" <njm@njm.f2s.com>
To:        freebsd-questions@freebsd.org
Subject:   Re: Calculate the time of last modification of a file
Message-ID:  <20061227165015.GA38514@ariel.njm.f2s.com>
In-Reply-To: <20061227155317.GC95520@ns2.wananchi.com>
References:  <20061227155317.GC95520@ns2.wananchi.com>

next in thread | previous in thread | raw e-mail | index | archive | help
On Wednesday, 27 December, 2006 at 18:53:17 +0300, Odhiambo Washington wrote:
> Hiya,
> 
> I hope you had a merry Christmas ;)
> 
> I am trying to determine the time of last modification of a file,
> on FreeBSD.
> 
> The following code achieves the same on Linux:
> 
> 
> # AGE = (current time) - (time of last modification of "$FILE")
> # please check your systems 'stat' command!
> AGE=$(($(date +%s) - $(stat -c '%Y' "$FILE")))
> 
> test $AGE -lt $DELAY && {
>         echo -n yes
>         exit 0
> }

I *think* what you are looking for is:

  stat -f '%Sm' -t '%s'

There is probably a much easier way to do that, but I couldn't find it
in the five minutes I had to spare.  :-)


Cheers,
       Nick.
-- 
Please do not CC me on replies, I read the list and don't need the dupes.




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20061227165015.GA38514>