[clug] CLUG meeting 21 August 2003
Stephen Jenkin
sjenkin at pcug.org.au
Mon Aug 18 13:31:53 EST 2003
My 2c :-)
set -- `cal $mon $year | tail +3|cut -c 13-14`
thurs=$4
The 'tail +3' removes the first 3 lines - the headers
The -c 13-14 picks out the columns that contains thursdays.
The first version tested for a blank 1st var (( [ -z "$1" ] && shift ))
But it wasnt necessary - the shell only loaded the non-balnk variables.
Tested for all months this year with bash on Solaris [hopefully 'cal'
output is the same]
HTH
cheers
sj
Steve Jenkin, Unix Sys Admin
0412 786 915 (+61 412 786 915)
PO Box 48, Kippax ACT 2615, AUSTRALIA
On Mon, 18 Aug 2003, Michael Still wrote:
> On Mon, 18 Aug 2003, Brad Hards wrote:
>
> > By my calendar ( http://korganizer.kde.org/ ), that is only the third
> > Thursday. I'd normally not be too worried (heh, as long as it happens!) but
> > I'm away this week, so I'd prefer it on the 28 Aug.
>
> Hey, that's twice in one year! I stand corrected. So, here's the script
> that generates that email:
>
> -------
> #!/bin/bash
>
> export day=`date +"%d"`
> export month=`date +"%B"`
> mon=`date +"%m"`
> export year=`date +"%Y"`
>
> thurs=`cal $mon $year | head -6 | tail -1 | cut -f 5 -d " "`
> nthurs=$(( $day + 3 ))
> export thurs
>
> if [ $nthurs = $thurs ]
> then
> ./subst.pl < template | mail -s "CLUG meeting $thurs $month $year" mikal
> else
> echo "nothing" | mail mikal
> fi
> -----
>
> As a challenge, anyone care to fix it so that months with no Thursday on
> the first line don't cause this bug?
>
> Cheers,
> Mikal
>
> --
>
> Michael Still (mikal at stillhq.com) | Stage 1: Steal underpants
> http://www.stillhq.com | Stage 2: ????
> UTC + 10 | Stage 3: Profit
>
>
More information about the linux
mailing list