[lug] Date Conversion Routine

David Morris boru at frii.com
Mon Jun 19 14:18:57 MDT 2000


I have a slight problem I hope the group can help me with:

I am working on a project that uses dates in both Year/Month/Day *and*
Year/Day of Year formats.  I am writing a shell script that will take
files with one of these two date formats as the filename, and sort the
files into a directory structure based off of the date.

Unfortunately, we cannot control the filenames, so we have to deal
with both. :(

The question:  In the shell script, I need to convert Day of Year to
Month and Day, and the reverse.  I know linux can use the 'date -d ...',
but I need this shell script to work with both LINUX and SunOS 5.6
(Solaris 2.6).  Solaris does not allow the 'date -d ...' command, so I
need an alternative.

Anyone on the group know of a UNIX command, awk script, small C
program, etc. that can do this conversion?

--David





More information about the LUG mailing list