Unix Programming - get file timestamp

This is Interesting: Free IT Magazines  
Home > Archive > Unix Programming > November 2005 > get file timestamp





You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

Author get file timestamp
bill

2005-11-08, 6:29 pm

Anyway to grab a file's timestamp (date, time, seconds) using straight
Unix Shell commands or ksh bultin? (not GNU, not perl, not C)

Bit Twister

2005-11-08, 6:29 pm

On 8 Nov 2005 09:44:14 -0800, bill wrote:
> Anyway to grab a file's timestamp (date, time, seconds) using straight


man stat
Jordan Abel

2005-11-08, 6:29 pm

On 2005-11-08, bill <quitspam@hotmail.com> wrote:
> Anyway to grab a file's timestamp (date, time, seconds) using straight
> Unix Shell commands or ksh bultin? (not GNU, not perl, not C)


ls(1) -- or stat(1), less friendly but will give you all three
timestamps in unix epoch format.
Gordon Burditt

2005-11-08, 6:29 pm

>Anyway to grab a file's timestamp (date, time, seconds) using straight
>Unix Shell commands or ksh bultin? (not GNU, not perl, not C)


Yes. If you don't need the time down to the second, you can parse
the output of "ls -l". Otherwise you can use the BSD program "stat",
if you consider that standard enough. You can get any time format
strftime() will give to you.

% stat -f "%Sm" .
Nov 8 00:59:08 2005
% stat -f "%Sm" -t "%Y%m%d%H%M%S" .
20051108005908
%

Instead of m (modification time), you can use a (access time) or
c (inode change time).


Gordon L. Burditt
Sponsored Links






Free braindumps | Software forum | Database administration forum

Copyright 2003 - 2008 webservertalk.com