Linux cal and ncal command

Updated: 11/06/2021 by Computer Hope
cal and ncal command

On Unix-like operating systems, the cal and ncal commands display a formatted calendar in the terminal.

Description

By default, the calendar displayed by cal looks like this:

     April 2019       
Su Mo Tu We Th Fr Sa  
    1  2  3  4  5  6  
 7  8  9 10 11 12 13  
14 15 16 17 18 19 20  
21 22 23 24 25 26 27  
28 29 30

The ncal ("new cal") command provides the same functions of cal, but it can display the calendar vertically (with weeks in columns). On systems with ncal installed, cal is often a symbolic link to ncal. It behaves like the original cal if you use the name cal to run the program.

If no options are specified, cal and ncal display the current month, with the current day highlighted.

Syntax

cal [month] [year] [-m month] [-y year] [-h] [-3] [-1] [-A num] [-B num]
    [-d YYYY-MM] [-j] [-N]
ncal [month] [year] [-m month] [-y year] [-h] [-3] [-1] [-A num] [-B num]
     [-d YYYY-MM] [-J] [-C] [-e] [-o] [-p] [-w] [-M] [-S] [-b]

Options

The following options are available in both cal and ncal:

Option Description
-h Don't highlight today's date.
-m month Specify a month to display. The month specifier is a full month name (e.g., Februiary), a month abbreviation of at least three letters (e.g., Feb), or a number (e.g., 2). If you specify a number, followed by the letter f or p, the month of the following or previous year, respectively, display. For instance, -m 2f displays February of next year.
-y year Specify a year to display. For example, -y 1970 displays the entire calendar of the year 1970.
-3 Display last month, this month, and next month.
-1 Display only this month. This is the default.
-A num Display num months occurring after any months already specified. For example, -3 -A 3 displays last month, this month, and four months after this one; and -y 1970 -A 2 displays every month in 1970, and the first two months of 1971.
-B num Display num months occurring before any months already specified. For example, -3 -B 2 displays the previous three months, this month, and next month.
-d YYYY-MM Operate as if the current month is number MM of year YYYY.

Options: cal

The following options are available only in cal:

Option Description
-j Display a Julian calendar, instead of the default Gregorian calendar. All days are numbered from January 1, rather than from the beginning of the month.
-N Behave as if you ran ncal, using its options and display output.

Options: ncal

The following options are available only in ncal:

Option Description
-J Display a Julian calendar, instead of the default Gregorian calendar. All days are numbered from January 1, rather than from the beginning of the month. If combined with -o, display the date of Orthodox Easter according to the Julian calendar.
-e Display the date of Easter for western calendars. This option exists because Easter is a defining date when calculating traditional calendar dates.
-o Display the date of orthodox Easter.
-p Print country codes and "switching days" for switching from Julian to Gregorian calendars in various countries.
-w Print the number of the week under each week column.
-C Behave as if you ran cal, using its options and display output.
-M Display weeks with Monday as the first day.
-S Display weeks with Sunday as the first day. This is the default.
-b Use the calendar display format of cal.

Examples

cal

Display the calendar for this month, with today highlighted.

cal -h

Same as the previous command, but do not highlight today.

cal -3

Display last month, this month, and next month.

cal -y

Display this entire year's calendar.

cal -y 2000

Display the entire year 2000 calendar.

cal 2000

Same as the previous command.

cal -m December

Display the calendar for December of this year.

cal -m Dec

Same as the previous command.

cal -m 12

Same as the previous two commands.

cal 12

Same as the previous three commands.

cal 12 2000

Display the calendar for December 2000.

ncal

Display this month's calendar, with weeks arranged vertically rather than horizontally.

ncal -y

Use a vertical calendar representation, displaying the entire year.

calendar — Display appointments and reminders.