Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!purdue!bu-cs!husc6!ogccse!littlei!omepd!merlyn From: merlyn@intelob.intel.com (Randal L. Schwartz @ Stonehenge) Newsgroups: comp.unix.questions Subject: solution in Perl (was Re: File Modification Dates) Summary: very brief Perl code attached Message-ID: <4404@omepd.UUCP> Date: 10 May 89 17:30:46 GMT References: <207@psgdc> Sender: news@omepd.UUCP Reply-To: merlyn@intelob.intel.com (Randal L. Schwartz @ Stonehenge) Organization: Stonehenge; netaccess via BiiN, Hillsboro, Oregon, USA Lines: 28 In article <207@psgdc>, rg@psgdc (Dick Gill) writes: [wants code to get readable modtime from filename] | I'll be happy to get a C program, shellscript or anything else | that I can call from a Bourne shell script. Ok, be happy. Here's a very brief Perl program to do what you want: ################################################## snip snip #!/usr/bin/perl @s = stat($ARGV[0]); @t = localtime($s[9]); printf "%04d/%02d/%02d %02d:%02d:%02d\n", 1900+$t[5], 1+$t[4], $t[3], $t[2], $t[1], $t[0]; ################################################## snip snip What? You don't have Perl? You'll probably have to write a small C program that does the above as: (1) take the argument, (2) fstat it, (3) look at the "mtime" field, (4) run it through "localtime", and (5) print the result. Or get Perl. (Yeay, Larry!) Just a Perl hacker, -- ***** PLEASE NOTE THE NEW ADDRESS ***** /=Randal L. Schwartz, Stonehenge Consulting Services (503)777-0095===\ { on contract to BiiN, Hillsboro, Oregon, USA, until 14 May 1989 } { ...!uunet!tektronix!biin!merlyn } { or try after 15 May 1989 } \=Cute quote: "Welcome to Oregon... home of the California Raisins!"=/