FInding the last day of the previous month, from the shell: cal `date --date 'last month' '+%m'` `date '+%Y'` | grep . | fmt -1 | tail -1