I had coded the below logic in Windows batch scripting and I need to replicate the same in Unix.# Calculating  Yesterday's Datefor /F tokens=1-4 delims=/-  %%a in ('date/T') do set  DY=%%cfor /F tokens=1-4 delims=/-  %%a in ('date/T') do set  MON=%%bfor /F tokens=1-4 delims=/-  %%a in ('date/T') do set /a YEAR=%%dif [ $DY==08  ]; then DAY=8 fiif [  $DY==09 ]; then  DAY=9 fiif [ $MON==08 ]; then  MONTH=8 fiif [ $MON==09 ]; then  MONTH=9 fiif [ $DY -ne 08 ]; then  if [ $DY -ne 09 ]; then DAY=%DY% fi fiif [ $MON -ne 08 ]; then  if [ $MON -ne 09 ]; then MONTH=%MON% fi fiPREVDAY=%DAY%-1PREVMONTH=%MONTH%-1PREVYEAR=%YEAR%-1ds=%YEAR%_%MONTH%_%PREVDAY%-  if [ %DAY%==1 ]; then if [ %PREVMONTH%==1 ] then ds=%YEAR%_%PREVMONTH%_31- fi fiif [  %DAY%==1 ]; then if [ %PREVMONTH%==2 ] then ds=%YEAR%_%PREVMONTH%_28- fi fiif [ %DAY%==1 ]; then if [ %PREVMONTH%==3 ] then ds=%YEAR%_%PREVMONTH%_31- fi fiif [  %DAY%==1 ]; then if [ %PREVMONTH%==4 ] then ds=%YEAR%_%PREVMONTH%_30- fi fiif [  %DAY%==1 ]; then if [ %PREVMONTH%==5 ] then ds=%YEAR%_%PREVMONTH%_31- fi fiif [ %DAY%==1 ]; then if [ %PREVMONTH%==6 ] then  ds=%YEAR%_%PREVMONTH%_30- fi fiif [  %DAY%==1 ]; then if [ %PREVMONTH%==7 ] then ds=%YEAR%_%PREVMONTH%_31- fi fiif [  %DAY%==1 ]; then if [ %PREVMONTH%==8 ] then ds=%YEAR%_%PREVMONTH%_31- fi fiif [  %DAY%==1 ]; then if [ %PREVMONTH%==9 ] then ds=%YEAR%_%PREVMONTH%_30- fi fiif [  %DAY%==1 ]; then if [ %PREVMONTH%==10 ] then ds=%YEAR%_%PREVMONTH%_31- fi fiif [  %DAY%==1 ]; then if [ %PREVMONTH%==11 ] then ds=%YEAR%_%PREVMONTH%_30- fi fiif [  %DAY%==1 ]; then if [ %PREVMONTH%==0 ] then  ds=%PREVYEAR%_12_31- fi fi
Converting windows date logic into Unix
shell script;scripting