LinuxCommandLibrary

cal

Display a calendar

TLDR

Display a calendar for the current month

$ cal
copy

Display a calendar for a specific year
$ cal [year]
copy

Display a calendar for a specific month and year
$ cal [month] [year]
copy

SYNOPSIS

cal [OPTIONS] [[MONTH] YEAR]
cal [OPTIONS] [DAY] MONTH YEAR

PARAMETERS

-3
    Display the previous, current, and next month.

-j
    Display Julian dates (day of the year, 1-365 or 1-366).

-y
    Display a calendar for the entire year specified or the current year.

-m month
    Display the calendar for a specific month (1-12) of the current or specified year.

-s
    Set Sunday as the first day of the week, overriding locale settings.

-w
    Display week numbers (1-52 or 1-53) for each week.

DESCRIPTION

The cal command is a classic Unix utility used to display a calendar in the terminal. By default, when invoked without any arguments, it shows the calendar for the current month with the current day highlighted. It can display a specific month of a given year, or even an entire year's calendar.

One of its notable historical features is its accurate representation of the transition from the Julian calendar to the Gregorian calendar, which occurred in September 1752 in Great Britain and its colonies. This historical anomaly, where 11 days were removed from the calendar, is correctly depicted by cal, making it a fascinating tool for historical date lookups as well as current ones. Its simplicity, speed, and omnipresence on Unix-like systems make it a fundamental utility for quickly checking dates.

CAVEATS

The first day of the week displayed by cal can vary depending on the system's locale settings. Users should be aware that while cal historically handles the 1752 calendar change, its primary function is basic calendar display rather than advanced date calculations or scheduling. For more feature-rich calendar views, consider ncal.

HIGHLIGHTING SPECIFIC DATES

You can highlight a specific day by providing the day, month, and year as arguments. For example, to view December 25, 2024, with that day highlighted, you would use:
cal 25 12 2024

LOCALE IMPACT

The default first day of the week (Sunday or Monday) can vary based on the system's configured locale. Use the -s (Sunday) or -L (Monday/ISO 8601) options to explicitly control this.

HISTORY

cal is one of the oldest standard Unix commands, dating back to the early days of AT&T Unix. Its original implementation is notable for correctly handling the historical calendar change in September 1752, when the British Empire adopted the Gregorian calendar by omitting 11 days. This specific detail highlights its deep roots in Unix history and its commitment to precise date representation, even for historical anomalies. It has remained largely unchanged due to its fundamental utility and simplicity.

SEE ALSO

date(1), ncal(1)

Copied to clipboard