The Cal command in Linux: show the calendar in terminal

The commandcalis a simple but powerful tool that allows you to view calendars directly in the terminal of any Linux distribution. Although at first sight it may seem a minor utility, its utility becomes evident when you need to quickly consult dates, plan tasks or simply check the day of the week of an event without leaving the command line.

What is the lime command?

Original of Unix systems,calIt belongs to the set of basic utilities that are pre-installed in virtually all modern distruses. Its main function is to print a monthly or annual calendar in text format, taking advantage of the width of the terminal to present the information in a clear and legible way. It does not require external units and its consumption of resources is virtually zero.

Basic syntax

The simplest way to invokecalis to execute it without arguments:

lime

This will show the current month's calendar, highlighting today. If you want to consult a specific month and year, just provide the numerical values:

cal per month

For example,cal 9 2025will show September 2025. It is also possible to request the full one year calendar with the option-yor simply indicating the year as the only argument:

cal 2025

or:

lime and 2025

Both forms produce a 12-month exit, each in its own block.

Examples of use

  • Show the current month calendar:cal
  • See February 2024:cal 2 2024
  • Get the full calendar of 2023:cal 2023
  • Show three consecutive months (previous, current and next) with the option-3: cal -3
  • Show the week number next to each date using-w: cal -w

Useful options

  • -1: Force one month display (default value).
  • -3: It shows the previous month, the current and the next.
  • -s: Consider Sunday as the first day of the week (BSD compatibility).
  • -m: Consider Monday as the first day of the week (default value in most GNU versions).
  • -j: Shows the Julian day (day of the year) instead of the conventional number.
  • -y: Show the full calendar of the specified year.
  • -w: Print the ISO week number next to each date.
  • -h: Disable the highlight of the current day (useful when redirecting output to a file).

Customization and format

Althoughcalis designed for a fast and legible output, it can be combined with other terminal tools to adapt its appearance. For example, usencal(a variant showing the calendar in vertical format) or applying colors byawkand ANSI codes:

lime | awk '{if (NR = 1) print "033 [1; 34m" $0 "033 [0m '; else print $0} '

This command colors the first line (the name of the month and year) in bright blue. The output can also be redirected to a file to create a permanent reminder:

cal and 2025 > calendar _ 2025.txt

Or integrate it into shell scripts that need to validate dates:

if [ $(date +% d) -eq $(lime | awk'NR = = 3 {print $3} '); then I do "Today is the first day of the month"; fi

The versatility ofcallies in its simplicity: it does not need prior configuration and responds instantly, making it a perfect ally for system administrators, developers and any user who usually works on the command line.

History and evolution

The commandcalappeared initially in version 7 of Unix in the late 1970s. Since then it has been covered by multiple systems, including Linux distributions and BSD systems. Although its essential functioning has remained the same, over time, options such as-jfor the Julian day or-wfor the ISO week number, adapting it to modern needs without losing its light tool essence.

Alternatives and supplements

There are other utilities that can be used as a supplement or substitute for use.ncalshows the calendar in vertical layout, which is useful when you want to see several months under each other.gcal, part of the GNU project, offers advanced features such as the incorporation of public holidays and the ability to generate calendars in different output formats. However, for most of the daily rapid consultation tasks,calremains the most direct and efficient option.

Conclusion

The commandcalmay seem a minor tool, but its ability to show calendars immediately and without dependencies makes it indispensable in many scenarios. From a quick date consultation to the generation of annual reports, its intuitive syntax and flexible options allow it to be adapted to almost any need. The next time you need to know which day a specific date falls, remember to just typecaland let the terminal do the rest.

This work is under aCreative Commons License Attribution 4.0 International for Francesc Roig francesc @ vivaldi.net.

EnglishenEnglishEnglish