I am using the below script to get yesterday date, but it is giving date of day before yesterday. Right now its 080906 but this code is giving 080904. And my requirement is 080905.
#!/bin/sh
CurrentDate=`TZ="GMT+24" date +'%y%m%d'`
echo $CurrentDate;
Using the TZ variable to manipulate the date is unreliable.
If possible, use one of the versions of date that can use a different date (GNU and *BSD), or try the date shell function from Chapter 8 of my book: 8: The Dating Game
I think where he was getting confused, he wasn't outputting the time, he was just outputting mm/dd/yy so depending on the time he ran the command it could of reported yesterdays date correctly for him, but other times it would of reported current date.