How do you find the date for yesterday from the shell?

 

On Linux servers use the date command as follows.

udate=`(date --date='yesterday' '+%d%m%y')`

 

If you have perl installed on your Unix server then try the following

perl -e'@x=localtime time-86400;printf"%2d%02d%04d\n",$x[3],$x[4]+1,$x[5]+1900'

or

perl -le 'print scalar localtime time - 86400'

or

udate=`perl -e'@x=localtime time-86400;printf"%2d%02d%02d\n",$x[3],$x[4]+1,$x[5]-100'`