Search code examples
linuxshellunixdatesunos

Get Yesterday's date in solaris


I am running SunOS.

bash-3.00$ uname -a
SunOS lvsaishdc3in0001 5.10 Generic_142901-02 i86pc i386 i86pc

I need to find Yesterday's date in linux with the proper formatting passed from command prompt. When I tried like this on my shell prompt-

bash-3.00$ date --date='yesterday' '+%Y%m%d'
date: illegal option -- date=yesterday
usage:  date [-u] mmddHHMM[[cc]yy][.SS]
        date [-u] [+format]
        date -a [-]sss[.fff]

I always get date illegal option, why is it so? Is there anything wrong I am doing?

Update:-

bash-3.00$ date --version
date: illegal option -- version
usage:  date [-u] mmddHHMM[[cc]yy][.SS]
        date [-u] [+format]
        date -a [-]sss[.fff]

Solution

  • Try this below thing. It should work

    YESTERDAY=`TZ=GMT+24 date +%Y%m%d`; echo $YESTERDAY