How to read file modification date (mm-dd-yy) in Korn

How to read file modification date (mm-dd-yy) in Korn

Post by Dmitri Moor » Thu, 17 Jan 2002 02:28:20



hi,
can anyone tell me how to read the file modification time (mostly interested
in the year) into a variable in Korn shell? ls -l gives me only "mm dd" for
files newer then 6 months old. I need to be able to extract a numeric value,
so later i could prepend it to a file name.

Thank you!!!

 
 
 

How to read file modification date (mm-dd-yy) in Korn

Post by Matthew Land » Thu, 17 Jan 2002 03:56:53



> hi,
> can anyone tell me how to read the file modification time (mostly interested
> in the year) into a variable in Korn shell? ls -l gives me only "mm dd" for
> files newer then 6 months old. I need to be able to extract a numeric value,
> so later i could prepend it to a file name.

> Thank you!!!

This is simple with perl.  You can get the epoch seconds modification
time into a KSH variable by the command below.

 MTIME=$(perl -e 'print $mtime = (stat("filename"))[9], "\n";')

 - Matt
--
_______________________________________________________________________

  IBM High Speed Interconnect - Fibre Channel I/O Dev/Test/Support
   << Comments, views, and opinions are mine alone, not IBM's. >>

 
 
 

How to read file modification date (mm-dd-yy) in Korn

Post by Michael Heimin » Thu, 17 Jan 2002 06:25:58




18:28:

Quote:> hi,
> can anyone tell me how to read the file modification time (mostly
> interested in the year) into a variable in Korn shell? ls -l gives
> me only "mm dd" for files newer then 6 months old. I need to be able
> to extract a numeric value, so later i could prepend it to a file
> name.

> Thank you!!!

$ export TY=`date +%Y`

$ ls -l | awk -v a=$TJ '{if ($8~/:/)print $6,$7,a,$NF;else print
$6,$7,$8, $NF}'

Could work, if this is wat you want. However, there may be problems
with filename containing sad white spaces....Try 'nawk' on Solaris.

Michael Heiming
--
Remove the +SIGNS case mail bounces.

 
 
 

1. Changing all date fields from mm/dd/yy to dd/mm/yy

Please, I'm looking for a way to change all date fields in a specified
file, like this:

solaris> cat file

05/23/06      03/12/06

07/10/06                   11/12/06           09/20/06

      03/11/06

I need change all date field from mm/dd/yy to dd/mm/yy, like this:

solaris> ./script < cat file

23/05/06        12/03/06

10/07/06                 12/11/06             20/09/06

       11/03/06

Thanks !

2. how to redirect trafic

3. Files modified since yy/mm/dd hh:mm

4. 3rd party 24bit graphic card

5. Sort by First Date Field (MM/DD/YY)

6. telnet: Unable to connect to remote host: Connection refused, ok second or third try.

7. How to translate date in dd/mm/yy format

8. 2.5.7-gregkh-1 (USB stuff)

9. How to convert Posix date to YY/MM/DD ?

10. How to convert Unix date to DD/MM/YYYY HH:MM:SS

11. Compare file modification date using tcsh built-ins

12. sort MM/DD/YY in reverse chron order with -k...

13. HELP: C prog to get mm/dd/yy format