Get previous month regardless of days
The usual wisdom is use the 15 of this month. Then subtract 1 month:
$ nowmonth=$(date +%Y-%m)
$ date -d "$nowmonth-15 last month" '+%Y%m'
201602
The usual wisdom is use the 15 of this month. Then subtract 1 month:
$ nowmonth=$(date +%Y-%m)
$ date -d "$nowmonth-15 last month" '+%Y%m'
201602