Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 27 Dec 2006 10:54:44 -0600
From:      Dan Nelson <dnelson@allantgroup.com>
To:        Odhiambo Washington <wash@wananchi.com>, freebsd-questions@freebsd.org
Subject:   Re: Calculate the time of last modification of a file
Message-ID:  <20061227165444.GA46391@dan.emsphone.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
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



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