Fun UNIX Shell Tricks
I wanted to know what was the last date of the preceding month to now… regardless of when now is… The UNIX/Linux cal command came to the rescue: cal -3 | cut -c1-16 | grep -v “^ *$” | tail -1 | sed -e ‘s/^..* \([23][0-9]\)/\1/’ It turns out you need a fairly modern version [...]