Monday, November 06, 2006

Command Line Calendars on Linux (& Cygwin!)

One thing that never ceases to amaze me since switching to Linux at home is how useful and efficient the command line can be. The 'cal' command is another great example of this. (Also note that the cal command works in Cygwin too, provided you've installed the util-linux package.)

If you need a quick glance at the calendar for the current month, just type 'cal' at the command line and you get a neat little calendar highlighting the current day as shown below:



But say you want to see the calendar for a future or past month. Again, very efficiently you just type 'cal mm yyyy' where xx is the month and yyyy is the year. Just like this:



Also useful is the -y switch which will display a complete calendar for the current year:


And of course you can see the complete calendar for any year you want by preceding the -y switch with the year itself like so:


So there you have it. A little useful tip for displaying calendars at the Linux (or Cygwin) command line. There are of course many other options. So check out the man page for the cal utility by typing: 'man cal' and tinker away!

3 comments:

Earl Moore said...

Hi Richard:

For general information, these calendar commands also work from the Mac's OS X command line. The only difference I noticed was when specifing a yearly calendar for a specific year in OS X the year has to be specified after the -y flag...as in " cal -y 2007 ". It appears you specified the year before the -y flag. OS X having this function isn't really surprising since it's based upon BSD.

RichardQuerin said...

Hi Earl,

Yeah, I forget sometimes that OS X has BSD Unix under the hood :) I used to work on Unix back in my graduate school days (writing some structural analysis software for my thesis) but it never really stuck on me back then. I was strictly a DOS/Windows gamer in those days.... :o

Erwin Quita said...

nice! thanks for the post!