date +%Y-%m
Echo the previous month in YYYY-MM format:
echo $(if [ $(expr $(date +%m) - 1) -eq 0 ]; then echo $(expr $(date +%Y) - 1)-12; else if [ $(expr $(date +%m) - 1) -gt 9 ]; then echo $(date +%Y)-$(expr $(date +%m) - 1); else echo $(date +%Y)-0$(expr $(date +%m) - 1); fi; fi)