Hacker News new | ask | show | jobs
by adamrmcd 1480 days ago
Often I use cal to find the previous or next month. I never understood why two parameters it assumes `cal mm yyyy` but when one parameter is provided assumes `cal yyyy` instead of `cal mm`.

ie, I just want to see April of this year: but `cal 4` returns Jan-Dec 0004 CE <!>

`cal -3` is perfect!

2 comments

Your cal likely also recognizes month names, try "cal apr" for April of this year.
Mine does not

~ $ cal apr

cal: year `apr' not in range 1..9999

Which cal? It is a relatively simple program that has seen many implementations and extensions. The cal I had in mind was the version from the util-linux package, it is commonly found in Linux distributions and supports full or abbreviated month names as arguments.
Gotcha. This is the one pre-installed on MacOS 11.6.
`cal -m 4` should work for that as well.