Five things you should know about the Linux
cal command. There are
many, many, more features listed in the man page but these are the
ones you should know.
cal command appeared in 1973 in what was called “Version 5
AT&T UNIX”. Linux and macOS (and all *BSD systems) have very
different clones. Check the man page for details.
1. The default is the current month
Run it with no parameters and you get the current month, with today’s date highlighted.
cal -3 shows last and next month too.
-3 flag shows last, current, and next month. This is typically
how I run it. It gives a broad overview and is faster than switching
to my browser, opening Google Calendar, and clicking around.
cal -y shows the entire year
You can see the entire year with the
cal x y shows a month x of year y
I never seem to remember which comes first, the month or the year. If you know of a good mnemonic device to help remember, please post in the comments.
My mother always told me that I was born on a Monday and would sing the nursery rhyme. Here’s how you can verify that I’m really “fair of face”:
cal x shows year x
Given a single numeric paremeter,
cal shows the entire year. So,
cal 2021 shows (as of this writing) next year’s calendar.
Cal is very literal.
cal 21 shows the year 21, not the year 2021.
5. September 2, 1752 is not a bug.
A common trick to play on people is to tell them that you found a bug in and show them September, 1752.
That’s the month that England switched from the Julian to Gregorian Calendar. The two calendars were out of sync by 10 days.
Different countries switched on different months.
ncal (“new cal”)
knows when different countries changed. Russia didn’t change until
ncal on FreeBSD, macOS, and other BSD-derived systems.
ncal are hard links to the same binary. The
binary looks to see which name was used. If it is run as
tries to be backwards compatible with the original Unix command. When
it is run as
ncal it offers more formats and options.