Command line Calendar utilities in Ubuntu/Debian

In this article, we cover command line Calendar utilities in Debian/Ubuntu. We are used to looking at calendar from our systems’ task bar. But, did you know that we can also access calendar through a command-line interface. The three command-line tools we cover here –

  1. cal,
  2. gcal and,
  3. ncal.

But, first we have install relevant packages. For cal & ncal to work, open a terminal and issue the following –

# apt update
# apt install ncal

And, for gcal –

# apt update
# apt install gcal

cal and ncal

We start with cal command-line utility. cal command displays current month by default.

$ cal

Whereas, when it comes to ncal it offers an alternate layout. The weekdays are presented in rows with ncal.

$ ncal

What is the difference between cal and ncal?

While cal present weekdays horizontally (left-to-right) and ncal displays them in a vertical (top-to-bottom) layout. cal command was present in AT&T UNIX and ncal was used in FreeBSD. To keep compatibility with older Unix’s cal command, it would output 8 lines, as cal command was used in many CGI scripts.

Now, lets see some examples :

To Print for particular month and year –

cal (month) (year)

$ cal 6 2023

Display the previous, current and next month –

$ cal -3

And, print for a specific month –

cal -m (month)

$ cal -m 2

Note: if you use 23 instead of 2023 for year. Then, it would results for 23 AD instead of year 2023.

This one is interesting –

$ cal 9 1752

Skipped 11 Days in calendar? Yes, that is due to Gregorian Reformation.

gcal

gcal is GNU utility, it can calculate astronomical data, displays eternal holiday lists for countries around the world and fixed date lists for reminders.

To display current month of year –

gcal

Print previous, current and next months –

gcal .

And, print month of year –

gcal (month) (year)

gcal 6 2023

In conclusion, we have covered here various command line Calendar utilities like cal, ncal and gcal in Debian/Ubuntu.

Similar Posts