how to display time of file in seconds

  • Follow


$ ls -al
-rw-r--r--   1 Jogn       dba           19 Jul 19 15:04 test1

how to display time that file is last modified in seconds,not only 
hour:minute?

Thanks in advance


0
Reply newbie 7/19/2006 7:09:26 AM

Hi!

I don't know any command to do that.
Here's a little python prog if you can need that:

#!/usr/bin/env python

import posix
import time
import sys

lastModifyTime=posix.stat( sys.argv[1] ).st_mtime
actTime=time.time()
print "Last Modify was %d seconds ago\n" % ( actTime - lastModifyTime )


Instead of using st_mtime you can also use st_ctime, depending on what changes you
like to track.  Have a look to the stat(2) man page for an explanation of the fields.

HTH Ewald

newbie wrote:
> $ ls -al
> -rw-r--r--   1 Jogn       dba           19 Jul 19 15:04 test1
> 
> how to display time that file is last modified in seconds,not only 
> hour:minute?
> 
> Thanks in advance
> 
> 
0
Reply Ewald 7/19/2006 7:43:15 AM


newbie wrote:
> $ ls -al
> -rw-r--r--   1 Jogn       dba           19 Jul 19 15:04 test1
> 
> how to display time that file is last modified in seconds,not only 
> hour:minute?


man ls |grep second

0
Reply ISO 7/19/2006 8:03:37 AM

Thommy M. Malmstr�m wrote:
> newbie wrote:
> 
>>$ ls -al
>>-rw-r--r--   1 Jogn       dba           19 Jul 19 15:04 test1
>>
>>how to display time that file is last modified in seconds,not only 
>>hour:minute?
>
> man ls |grep second

Only on Sol.10 i believe - at least i couldn't find a
reference to the '-e' flag on Sol.8. For systems before
Sol.10 use either what Ewald Ertl mentioned in his post,
or use the 'stat' command on the file.

Regards,

	Frank
0
Reply Frank 7/19/2006 9:26:17 AM

Frank Fegert <fra.nospam.nk@gmx.de> wrote:
>> man ls |grep second

> Only on Sol.10 i believe - at least i couldn't find a
> reference to the '-e' flag on Sol.8. For systems before
> Sol.10 use either what Ewald Ertl mentioned in his post,
> or use the 'stat' command on the file.

I don't know of any 'stat' command on Solaris, and I wouldn't expect
python on a pre-10 machine either.

You could use perl if it's on the machine.

# perl -le 'print scalar localtime ((stat "/lib")[9])'
Mon Dec  5 14:49:33 2005

-- 
Darren Dunham                                           ddunham@taos.com
Senior Technical Consultant         TAOS            http://www.taos.com/
Got some Dr Pepper?                           San Francisco, CA bay area
         < This line left intentionally blank to confuse you. >
0
Reply Darren 7/19/2006 5:48:50 PM

Thanks all.

Darren Dunham's method would be more feasible for newbie.


"Darren Dunham" <ddunham@redwood.taos.com> wrote in message 
news:6guvg.51713$VE1.50232@newssvr14.news.prodigy.com...
> Frank Fegert <fra.nospam.nk@gmx.de> wrote:
>>> man ls |grep second
>
>> Only on Sol.10 i believe - at least i couldn't find a
>> reference to the '-e' flag on Sol.8. For systems before
>> Sol.10 use either what Ewald Ertl mentioned in his post,
>> or use the 'stat' command on the file.
>
> I don't know of any 'stat' command on Solaris, and I wouldn't expect
> python on a pre-10 machine either.
>
> You could use perl if it's on the machine.
>
> # perl -le 'print scalar localtime ((stat "/lib")[9])'
> Mon Dec  5 14:49:33 2005
>
> -- 
> Darren Dunham                                           ddunham@taos.com
> Senior Technical Consultant         TAOS            http://www.taos.com/
> Got some Dr Pepper?                           San Francisco, CA bay area
>         < This line left intentionally blank to confuse you. > 


0
Reply newbie 7/20/2006 12:55:13 AM

5 Replies
1486 Views

(page loaded in 0.072 seconds)

Similiar Articles:













7/20/2012 9:45:40 PM


Reply: