$ cal 04 2012 | awk 'NF <= 7 { print $7 }' | grep -v "^$" | tail -1
This is a little trickier than finding the last Sunday, because you know the last Sunday is in the first position of the last line. The trick is to use the NF less than or equal to 7 so it picks up all the lines then grep out any empty lines.
by David Winterbottom (codeinthehole.com)