As many of you know default date command on AIX doesn’t support “–date” parameter as Linux systems do. So, what can you do if you want to display another date in your shell script? There are some scripts roaming around the web, but the simplest thing i found is this. Get your time zone (let’s say +1) and substract 24 hours from it (we get 23). Then we change our timezone by setting TZ environment variable to new one and execute date command like this:
# YESTERDAY=$(TZ=EST23EDT date) # echo $YESTERDAY Mon 1 Mar 2010 12:06:33 # date Tue 2 Mar 2010 12:06:39
You can insert any number instead of number “23” used in this script (EST<any integer number>EDT). This allows you to add or subtract as many hours as you want.