From owner-freebsd-questions@FreeBSD.ORG Wed Dec 27 16:50:18 2006 Return-Path: X-Original-To: freebsd-questions@freebsd.org Delivered-To: freebsd-questions@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 6551516A40F for ; Wed, 27 Dec 2006 16:50:18 +0000 (UTC) (envelope-from njm@njm.f2s.com) Received: from outmail1.freedom2surf.net (outmail1.freedom2surf.net [194.106.33.237]) by mx1.freebsd.org (Postfix) with ESMTP id 2BD7D13C475 for ; Wed, 27 Dec 2006 16:50:18 +0000 (UTC) (envelope-from njm@njm.f2s.com) Received: from ariel.njm.f2s.com (i-195-137-21-170.freedom2surf.net [195.137.21.170]) by outmail1.freedom2surf.net (Postfix) with ESMTP id 5A34F504DC; Wed, 27 Dec 2006 16:50:17 +0000 (GMT) Received: from ariel.njm.f2s.com (localhost.njm.f2s.com [127.0.0.1]) by ariel.njm.f2s.com (8.13.8/8.13.6) with ESMTP id kBRGoG9C079941; Wed, 27 Dec 2006 16:50:16 GMT (envelope-from njm@ariel.njm.f2s.com) Received: (from njm@localhost) by ariel.njm.f2s.com (8.13.8/8.13.8/Submit) id kBRGoG8i079940; Wed, 27 Dec 2006 16:50:16 GMT (envelope-from njm) Date: Wed, 27 Dec 2006 16:50:15 +0000 From: "N.J. Mann" To: freebsd-questions@freebsd.org Message-ID: <20061227165015.GA38514@ariel.njm.f2s.com> Mail-Followup-To: freebsd-questions@freebsd.org, Odhiambo Washington References: <20061227155317.GC95520@ns2.wananchi.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20061227155317.GC95520@ns2.wananchi.com> X-Operating-System: FreeBSD 6.2-PRERELEASE User-Agent: Mutt/1.5.13 (2006-08-11) Cc: Subject: Re: Calculate the time of last modification of a file X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 27 Dec 2006 16:50:18 -0000 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.