I am creating a script that collects information from the previous month used for reporting:
So far I have the below variables:
#I used an array to get the previous month.
set -A months Dec Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov
x=`date +%m`
y=`expr $x - 1`
year=`date +%Y`
month=`perl -MPOSIX=strftime -le '@t = localtime; $t[3] = 1; $t[4]--;print strftime("%m", @t)'`
month_abv=`echo ${months[$y]}`
Variable output:
year=2017
month=04
month_abv=Apr
All I need now is the last day of the previous month.