From: John DuBois on
In article <8d9d9210-c93c-44e2-9fc6-b7b6daee6c2e(a)>,
Scott Bass <sas_l_739(a)> wrote:
>I'm writing a script (ksh) where the user enters a date parameter as
>-a "begin time"
>Job will not start until after begin time
>begin time is in the form of month:day:hour:minute where
>month 1-12, day is 1-31, hour is 0-23 and minute is 0-59.
>At least 2 fields must be given hour:minute, if 3 fields
>are given they are assumed to be day:hour:minute.
>I would like to add error checking in the script, rather than having
>the called utility choke on bad dates.
>I'd like to split the user parameter into fields, then check the
>fields in my script.

If you know there will be only one word in each field, as you might
legitimately assume in this case, you can split into fields with e.g.:

set -- ${foo//:/ /}
which will replace the colons with space and thus be split on them.
$1..$4 will be your fields.

If you don't want to make that assumption:

set -- $foo

There are some examples of date error-checking in this library, e.g. in

John DuBois spcecdt(a) KC6QKZ/AE