[X-Unix] shell script to determine 1st business day of month ?
David Ledger
dledger at ivdcs.demon.co.uk
Wed May 7 12:10:04 PDT 2008
At 10:40 -0500 7/5/08, Russell McGaha wrote:
>Folks;
> Do any of you know of a script callable from BASH, that will
>/ can say if today (or a given date) is the first business day of
>the month??
That sort of thing is very long winded to do in any shell. It's much
easier to use perl . This should work using ksh as the wrapper.
set -A timestamp 0 0 0 7 4 108
set -A ts $(perl -e 'use Time::Local;print join(" ",
localtime(timelocal(split /\s/, "'"${timestamp[*]}"'"))), "\n"')
echo ${ts[*]}
prints
0 0 0 7 4 108 3 127 1
echo ${ts[6]}
prints
3
Where the '7' and the '4' means 7th May (month - 1) and the 108 is
2008 - 1900. The '3' in the o/p is the day number = Wednesday (Sunday
= 0). (The 127 is the day of the year and the 1 means daylight
saving. The zeros are seconds, minutes and hours).
You can use this technique to determine the weekday of any date and
go from there.
David
--
David Ledger - Freelance Unix Sysadmin in the UK.
HP-UX specialist of hpUG technical user group (www.hpug.org.uk)
david.ledger at ivdcs.co.uk
www.ivdcs.co.uk
More information about the X-Unix
mailing list