December 31st, 2012, 05:35 PM
That should work for centuries, but not for general leap years. The process is it's a leap year if the year is exactly divisible by 4, unless it's a century where the year has to be eaxctly divisible by 100.
Either 'double-up' the tests, or do a bit more work and check for a century year beforehand, setting divisor to 400 or 4, depending on result, then use that to check the year.
Failing that, try:
if [ $(cal Feb $YY | tail -n +3 | wc -w) -eq 29 ]
echo "$YY is a leap year"
echo "$YY not a leap year"
The moon on the one hand, the dawn on the other:
The moon is my sister, the dawn is my brother.
The moon on my left and the dawn on my right.
My brother, good morning: my sister, good night.
-- Hilaire Belloc