From owner-freebsd-questions@FreeBSD.ORG Tue Jan 3 20:11:52 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 A62C8106564A for ; Tue, 3 Jan 2012 20:11:52 +0000 (UTC) (envelope-from freebsd@edvax.de) Received: from mx02.qsc.de (mx02.qsc.de [213.148.130.14]) by mx1.freebsd.org (Postfix) with ESMTP id 6B3228FC0A for ; Tue, 3 Jan 2012 20:11:52 +0000 (UTC) Received: from r56.edvax.de (port-92-195-26-82.dynamic.qsc.de [92.195.26.82]) by mx02.qsc.de (Postfix) with ESMTP id D480F1E494 for ; Tue, 3 Jan 2012 21:11:50 +0100 (CET) Received: from r56.edvax.de (localhost [127.0.0.1]) by r56.edvax.de (8.14.5/8.14.5) with SMTP id q03KBolv002311 for ; Tue, 3 Jan 2012 21:11:50 +0100 (CET) (envelope-from freebsd@edvax.de) Date: Tue, 3 Jan 2012 21:11:50 +0100 From: Polytropon To: FreeBSD Questions Message-Id: <20120103211150.41f1934d.freebsd@edvax.de> Organization: EDVAX X-Mailer: Sylpheed 3.1.1 (GTK+ 2.24.5; i386-portbld-freebsd8.2) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Subject: 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 Reply-To: Polytropon List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 03 Jan 2012 20:11:52 -0000 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 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? -- Polytropon Magdeburg, Germany Happy FreeBSD user since 4.0 Andra moi ennepe, Mousa, ...