Hi Perderabo,
i came across one of your script datecalc.ksh while i am searching for a script which validate the date.In tht i have a doubt at a particular part of code
could you please explain me wht this part of code signifies.i am new to unix shell scripting.
if ((!(year%100))); then
((!(year%400))) && leap=1
else
((!(year%4))) && leap=1
fi
feblength=28
((leap)) && feblength=29
print $feblength
return 0
As you should be able to tell from the variable names, it handles leap years. % is the modulo operator (commonly called "remainder" in primary school). In other words, if the year is evenly divisible by 4 (modulo is zero, so the conditional (( (year % 4) )) returns false; we invert that value with the exclamation mark) but not by 100 except if it's also divisible by 400, it's a leap year, and so February will have 29 days.