cana rich wrote:
> 
> Hello,
> 
>     I would like to make a diff in the date of a file from the copy to
> the dateday.
> 
> I mean i would like to know how many days has been left since the copy
> of the file.

The following bit of python code will do the job.  As set up, it
displays the days, hours, minutes, and seconds of delta time between any
two files.  I believe the one you want is creation time.

rickf

------------ tear here ----------------
#!/usr/bin/env python

import os, sys, time

def tmDiff(t1, t2):
   deltaTm = abs(t2-t1)
   M = deltaTm/60
   S = deltaTm%60
   H = M/60
   M = M%60
   D = H/24
   H = H%24
   strTm = '%dD-%dH-%dM-%dS'%(D,H,M,S)
   return strTm

if not os.path.exists(sys.argv[1]):
   print 'ERROR - not a valid file name:',sys.argv[1]
if not os.path.exists(sys.argv[2]):
   print 'ERROR - not a valid file name:',sys.argv[2]

st1 = os.stat(sys.argv[1])
st2 = os.stat(sys.argv[2])

ctm = tmDiff (st2[9], st1[9])
atm = tmDiff (st2[8], st1[8])
mtm = tmDiff (st2[7], st1[7])

print 'ctime diff:',ctm
print 'atime diff:',atm
print 'mtime diff:',mtm

-- 
If you are successfull they'll beat a path to your doorstep ...
     Picket signs firmly in hand!



-- 
redhat-list mailing list
unsubscribe mailto:[EMAIL PROTECTED]?subject=unsubscribe
https://listman.redhat.com/mailman/listinfo/redhat-list

Reply via email to