Subscribe to my feed  Google 

Wednesday, January 31, 2007

Print Unix File Timestamp Accurate Down to Seconds

As most of us know and need, ls -l shows us detailed information about files in a directory.

someone@somewhere:/opt/mozilla/icons $ ls -l
total 32
-rw-r--r-- 1 bin bin 1668 Mar 5 2004 mozicon16.xpm
-rw-r--r-- 1 bin bin 2944 Mar 5 2004 mozicon50.xpm

Here is a single perl command that can print the timestamp of files with full date and time, accurate down to the seconds:

perl -e 'foreach(@ARGV){$t =localtime ( ( ( stat ( $_ ) ) [9] ) ); printf("%-20s %s\n",$_,$t);}' *

Replace the asterisk at the end of the command with any filename or wildcard expression you require.

Technorati Tags: , , , , , ,

Labels:


Share
Digg This Story

Previous post:

1 Comments:

Blogger Jason Ennor thought

excellent! thanks.

December 01, 2007 3:19 AM  

Post a Comment

Links to this post:

Create a Link