Hello all. I'm writing a script that should work with some files being sure that them were created a concrete day (0, 1, 2 or 3 days before script execution). This task should be done under Solaris and Linux hosts with different versions (Solaris 8, 9 and 10, Suse 9 and 10) so I'm trying to make the script as generic as possible, trying to cover the whole system. To calculate the dates I'm doing the following:
counter=0
while [ $counter -le 3 ]
do
PreCommand=`expr "$counter" \* 24`
Day[$counter]=`TZ="$TimeZone"+"$PreCommand" date +"%d"`
DayOfWeek[$counter]=`TZ="$TimeZone"+"$PreCommand" date +"%a"`
MonthNumber[$counter]=`TZ="$TimeZone"+"$PreCommand" date +"%m"`
MonthName[$counter]=`TZ="$TimeZone"+"$PreCommand" date +"%b"`
YearLong[$counter]=`TZ="$TimeZone"+"$PreCommand" date +"%Y"`
YearShort[$counter]=`TZ="$TimeZone"+"$PreCommand" date +"%y"`
counter=`expr "$counter" + 1`
done
I've tested it in some machines and works perfectly, so in a Suse 9 an offset over 24h to TZ is ignored, so the result for today (28) is:
Day[0]=28
Day[1]=27
Day[2]=27
Day[3]=27
Does someone know why it happen, how to solve it or an alternative way valid under Linux and Solaris?
Thank you very much in advance
PS: the scripting language is ksh