Calculate the time of last modification of a file

Odhiambo Washington wash at wananchi.com
Thu Dec 28 03:57:24 PST 2006


* On 27/12/06 10:54 -0600, Dan Nelson wrote:
| In the last episode (Dec 27), Odhiambo Washington said:
| > 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
| > }
| 
| You can use "stat -f '%m' $FILE", which is identical to Linux's 
| "stat -c '%Y' $FILE" .

Bang!

Thank you so much, Dan!
 

	Best regards,
	Odhiambo Washington
	Systems Admin,
	Wananchi Online Ltd.

Voted ISP of the Year 2006
Computer Society of Kenya Annual Awards
30Th Nov., 2006 ­ Panari Hotel, Nairobi


DISCLAIMER: See http://www.wananchi.com/bms/terms.php
----------------------------------+-----------------------------------------
 Odhiambo WASHINGTON			. WANANCHI ONLINE LTD (Nairobi, KE)
 http://www.wananchi.com/email/		. 1ere Etage, Laptrust Plaza, Loita St.,
 Mobile: (+254) 722 743 223		. # 10286, 00100 NAIROBI
----------------------------------+-----------------------------------------
``It is always the best policy to speak the truth --
  unless, of course, you are an exceptionally good liar.'' (Jerome K Jerome)
     



More information about the freebsd-questions mailing list