[SunHELP] Solaris Date commands

Will Mc Donald sunhelp at sunhelp.org
Sun Nov 4 19:20:41 CST 2001


man touch

You should be able to read in the time for each $file from its header, use
the touch command to change the unix timestamp for $file (assuming this
doesn't mess with anything else using those timestamps) then allow you to
process them in date format using something like ls -t to read them in for
instance.

Will.

----- Original Message -----
From: "Gavin Winter" <gwinter at rlo.com.au>
> Hello all,
> I am new to shell scripting and I am attempting to solve a somewhat
complex
> problem. On our Solaris 8 box (SPARC) we have a dir with many files. Each
> file (flat text) has, in the header record, a timestamp field indicating
the
> date/time the file was created.  The files have to be processed in
timestamp
> order, i.e. oldest first.  The unix timestamp against the file is not a
> valid indicator of age in this case.
>
> And example of the timestamp field is as follows...
> 20011025015826
> (YYYYMMDDHH24MISS)
>
> I can loop through the files easily enough, reading in the date field but
> this make it very difficult to do comparisons between dates to find the
> oldest file. I think the easiest method would be to convert the string to
a
> date format, do a comparison on the date format (perhaps using seconds
from
> 1970 or similar) and proceed forthwith to date the files. However I cannot
> find any unix commands to help me do this.
>
> Does anyone have any advice to offer on this?
>
> regards
> Gavin Winter





More information about the SunHELP mailing list