From owner-freebsd-questions@FreeBSD.ORG Tue Jan 3 20:49:08 2012 Return-Path: Delivered-To: freebsd-questions@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 31B1C106566C for ; Tue, 3 Jan 2012 20:49:08 +0000 (UTC) (envelope-from dan@dan.emsphone.com) Received: from email2.allantgroup.com (email2.emsphone.com [199.67.51.116]) by mx1.freebsd.org (Postfix) with ESMTP id D30768FC15 for ; Tue, 3 Jan 2012 20:49:07 +0000 (UTC) Received: from dan.emsphone.com (dan.emsphone.com [199.67.51.101]) by email2.allantgroup.com (8.14.4/8.14.4) with ESMTP id q03Kn3F9058891 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Tue, 3 Jan 2012 14:49:03 -0600 (CST) (envelope-from dan@dan.emsphone.com) Received: from dan.emsphone.com (smmsp@localhost [127.0.0.1]) by dan.emsphone.com (8.14.5/8.14.5) with ESMTP id q03Kn3Rv084060 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Tue, 3 Jan 2012 14:49:03 -0600 (CST) (envelope-from dan@dan.emsphone.com) Received: (from dan@localhost) by dan.emsphone.com (8.14.5/8.14.5/Submit) id q03Kn2Pq084059; Tue, 3 Jan 2012 14:49:02 -0600 (CST) (envelope-from dan) Date: Tue, 3 Jan 2012 14:49:02 -0600 From: Dan Nelson To: Polytropon Message-ID: <20120103204902.GG24192@dan.emsphone.com> References: <20120103211150.41f1934d.freebsd@edvax.de> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20120103211150.41f1934d.freebsd@edvax.de> X-OS: FreeBSD 8.2-STABLE User-Agent: Mutt/1.5.21 (2010-09-15) X-Virus-Scanned: clamav-milter 0.97.2 at email2.allantgroup.com X-Virus-Status: Clean X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.2.6 (email2.allantgroup.com [199.67.51.78]); Tue, 03 Jan 2012 14:49:03 -0600 (CST) X-Scanned-By: MIMEDefang 2.68 on 199.67.51.78 Cc: FreeBSD Questions Subject: Re: Exact timestamp for sorting and renaming files according to creation order 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: Tue, 03 Jan 2012 20:49:08 -0000 In the last episode (Jan 03), Polytropon said: > For a sorting script, I'm currently searching for a method to get file > creation date and time as exactly as possible. The best resolution I > could get was seconds. In case more than one file is created within the > same second, it doesn't work precisely enough. It should work from sh > script. > > For the purpose of preparing the sort list (that will be sorted and then > be used as a template for renaming the files with a prefix and a counter), > I'm using the "stat" program which creates output like this: > > % stat -f "%N %B" -t "%Y-%m-%d_%H:%M:%S" 1.txt > 1.txt 2012-01-03_12:12:12 > > It's also possible to use the Epoch time format, but it doesn't provide a > solution better than seconds: > > % stat -f "%N %B" -t "%s" 1.txt > 1.txt 1325589132 If you ask for the date to be printed in "float" (F) format, it gives more precision. The default is unsigned int (U) format. % stat -f "%N %FB" /COPYRIGHT /COPYRIGHT 1306190895.046721049 > I've read the manuals for stat as well as for strftime (which is the > facility stat's -t parameter addresses), but found nothing that is more > precise than seconds. > > Does anyone have a suggestion how to precisely determine the order files > have been created? -- Dan Nelson dnelson@allantgroup.com