Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Mailing Lists -> Oracle-L -> RE: Year of Unix file
How about using stat(2)?
$ ls -l proc.txt
-rw-rw-r-- 1 oracle dba 3414 Jul 1 00:10 proc.txt
$ perl -e '$a=(stat "proc.txt")[9]; print int $a/31536000+1970,"\n"'
2001
There's a better way to convert seconds since epoch to year but for now I just divide it by number of seconds in a year and add 1970 to it.
The above perl one-liner is just a convenient way to call stat(2).
Yong Huang
yong321_at_yahoo.com
you wrote:
But the year replaces the time in the 8th field only when the last modification time for the file is more than 6 month (even if it is in the current year :)
For example, take a look at line 1,2 (less than 6 month old as of today) & 3,4,5 (over 6 months old as of today)..
-rw-rw-r-- 1 oracle dba 2880 Feb 5 08:05 junk.lst
-rwxrwx--- 1 oracle dba 410 Jan 30 11:08 show_all.ksh
-rwx------ 1 oracle dba 77 Jan 25 2001 t1
-rw-rw-r-- 1 oracle dba 3971 Jan 10 2001 my.lst
-rw-rw-r-- 1 oracle dba 720 Jan 7 2001 bdf.out
HTH... Regards,
Fat City Network Services -- (858) 538-5051 FAX: (858) 538-5051 San Diego, California -- Public Internet access / Mailing Liststo: ListGuru_at_fatcity.com (note EXACT spelling of 'ListGuru') and in the message BODY, include a line containing: UNSUB ORACLE-L (or the name of mailing list you want to be removed from). You may also send the HELP command for other information (like subscribing). Received on Sun Jul 29 2001 - 14:49:14 CDT
--------------------------------------------------------------------
To REMOVE yourself from this mailing list, send an E-Mail message
![]() |
![]() |