From owner-freebsd-questions@FreeBSD.ORG Wed Dec 27 16:54:45 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 7005116A407 for ; Wed, 27 Dec 2006 16:54:45 +0000 (UTC) (envelope-from dan@dan.emsphone.com) Received: from dan.emsphone.com (dan.emsphone.com [199.67.51.101]) by mx1.freebsd.org (Postfix) with ESMTP id 17C5F13C46D for ; Wed, 27 Dec 2006 16:54:44 +0000 (UTC) (envelope-from dan@dan.emsphone.com) Received: (from dan@localhost) by dan.emsphone.com (8.13.6/8.13.8) id kBRGsi88073336; Wed, 27 Dec 2006 10:54:44 -0600 (CST) (envelope-from dan) Date: Wed, 27 Dec 2006 10:54:44 -0600 From: Dan Nelson To: Odhiambo Washington , freebsd-questions@freebsd.org Message-ID: <20061227165444.GA46391@dan.emsphone.com> 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-OS: FreeBSD 6.2-PRERELEASE X-message-flag: Outlook Error 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:54:45 -0000 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" . -- Dan Nelson dnelson@allantgroup.com