From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 5117 invoked by alias); 26 Jul 2011 15:45:24 -0000 Mailing-List: contact zsh-users-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Users List List-Post: List-Help: X-Seq: 16143 Received: (qmail 25384 invoked from network); 26 Jul 2011 15:45:22 -0000 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-3.3 required=5.0 tests=BAYES_00,FORGED_HOTMAIL_RCVD2, FREEMAIL_FROM,RCVD_IN_DNSWL_MED,SPF_HELO_PASS,T_TO_NO_BRKTS_FREEMAIL autolearn=ham version=3.3.1 Received-SPF: pass (ns1.primenet.com.au: SPF record at m.gmane.org designates 80.91.229.12 as permitted sender) X-Injected-Via-Gmane: http://gmane.org/ To: zsh-users@zsh.org From: skullnobrains Subject: Re: Extract CTIME in zsh 4.2.3? Date: Tue, 26 Jul 2011 15:24:07 +0000 (UTC) Message-ID: References: <95E667D6-6AE4-4CDA-B420-30033315C886@tntluoma.com> <44613de005082113114c9f2092@mail.gmail.com> <16D53E3C-D453-414D-AB6C-3280FF5573CF@tntluoma.com> <44613de005082208246036665e@mail.gmail.com> <20050822153529.GA66@DervishD> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Complaints-To: usenet@dough.gmane.org X-Gmane-NNTP-Posting-Host: sea.gmane.org User-Agent: Loom/3.14 (http://gmane.org/) X-Loom-IP: 217.128.171.81 (Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.2.18) Gecko/20110628 Ubuntu/10.04 (lucid) Firefox/3.6.18) > In fact, it is not present in SUS. Probably it is present only > for a few filesystems, so it has to be retrieved in a non-portable > way. Under Linux, I don't recall now of any filesystem that > implements creation time for entries. It's not an operating system > problem, is a filesystem problem. Even in the case you can write > code for some UNIX flavour to retrieve that data, it will only work > for some particular filesystem. The VFS on top of that will only > store the st_atime, st_mtime and st_ctime values in the metadata. actually GNU/linux is definitely the only unix-like OS where you are likely to be unable to retrieve a file's ctime. "stat -f %c FILE" should be portable on any BSD os, including macosx and probably on any solaris distribution as well. you will need to use the "date" command in order to format the date as stat will return a timestamp. each system is likely to implement shorthands to retrieve the date in human readable form but in a less likely portable way. the shell you are using will probably make no difference as stat is usually either not a builtin or is system-dependant, but you can use `which stat` if you want to make sure the builtin will not be used. this is very sad, and i'd like to make clear i'm not looking forwards to start a flame war, but if you are running linux trying to make something portable, you probably should forget about using the shell, and switch to something like perl. on the other hand ls + sed is more than likely to be portable under any OS, but what you will retrieve in linux will probably not be the actual ctime of the file