I have scheduled a Bash script to run on the 1st of the month but I need to create 2 variables in it with the 1st and last date of the previous month, whatever those may be.
first=`date -d "02/05/2018" +"%Y%m01"`
last=`date -d "02/05/2018 + 1 month-5 day" +"%Y%m%d"`
RUNDATE="20180207"
y="${RUNDATE:0:4}"
m="${RUNDATE:4:2}"
d="${RUNDATE:6:2}"
RUNDATE_START=`date -d "$m/$d/$y" +"%Y%m01"`
RUNDATE_END=`date -d "$m/$d/$y + 1 month - $d day" +"%Y%m%d"`
20180201
20180228