[SunHELP] Solaris Date commands
sunhelp at sunhelp.org
sunhelp at sunhelp.org
Mon Nov 5 01:18:04 CST 2001
How about:
1. Reading the timestamp in each file
2. Write out the timestamp and filename to a temp file
3. Sort the file using `sort -n` (n is for numeric, but probably doesn't
matter since the date string is uniform in length.
4. Use the tempfile in a loop, reading a line at a time, either reading the
filename into a variable using read or awk { 'print $2' } to get the
filename. Do whatever you need to do in the loop.
5. Remove the tempfile.
-----Original Message-----
From: Gavin Winter [mailto:gwinter at rlo.com.au]
Sent: Sunday, November 04, 2001 5:18 PM
To: sunhelp at sunhelp.org
Subject: [SunHELP] Solaris Date commands
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
_______________________________________________
SunHELP maillist - SunHELP at sunhelp.org
http://www.sunhelp.org/mailman/listinfo/sunhelp
More information about the SunHELP
mailing list