getting a previous date in bash/unix
I am looking to get previous date in unix / shell script .
I am using the following code
date -d ’1 day ago’ +’%Y/%m/%d’
But I am getting the following error.
date: illegal option -- d
As far as I've read on the inetrnet , it basically means I am using a older version of GNU. Can anyone please help with this.
unix> uname -a
SunOS Server 5.10 Generic_147440-19 sun4v sparc SUNW,Sun-Fire-T200
Also The below command gives an error.
unix> date --version
date: illegal option -- version usage: date [-u] mmddHHMM[[cc]yy][.SS] date [-u] [+format] date -a [-]sss[.fff]
Several solutions suggested here assume
GNU coreutils being present on the system. The following should work on Solaris:
TZ=GMT+24 date +’%Y/%m/%d’