Linux / UNIX: displays a calendar and the date of easter with cal command

by on August 1, 2007 · 7 comments· LAST UPDATED August 10, 2007

in , ,

Q. date command displays date and time under a shell? How do I display calendar under Linux or UNIX?

A. date displays the Linux or UNIX system current date and time. The cal command displays a simple calendar in traditional format and ncal offers an alternative layout, more options and the date of easter. The new format is a little cramped but it makes a year fit on a 25x80 terminal. If arguments are not specified, the current month is displayed.

cal command

Just enter cal command as follows:
$ cal
Output:

    August 2007
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 31

ncal command

ncal command changes the output format:
$ ncal
Output:

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

Print calendar for year 2008

$ cal 2008
Output:

                               2008
       January               February                 March
Su Mo Tu We Th Fr Sa   Su Mo Tu We Th Fr Sa   Su Mo Tu We Th Fr Sa
       1  2  3  4  5                   1  2                      1
 6  7  8  9 10 11 12    3  4  5  6  7  8  9    2  3  4  5  6  7  8
13 14 15 16 17 18 19   10 11 12 13 14 15 16    9 10 11 12 13 14 15
20 21 22 23 24 25 26   17 18 19 20 21 22 23   16 17 18 19 20 21 22
27 28 29 30 31         24 25 26 27 28 29      23 24 25 26 27 28 29
                                              30 31
        April                   May                   June
Su Mo Tu We Th Fr Sa   Su Mo Tu We Th Fr Sa   Su Mo Tu We Th Fr Sa
       1  2  3  4  5                1  2  3    1  2  3  4  5  6  7
 6  7  8  9 10 11 12    4  5  6  7  8  9 10    8  9 10 11 12 13 14
13 14 15 16 17 18 19   11 12 13 14 15 16 17   15 16 17 18 19 20 21
20 21 22 23 24 25 26   18 19 20 21 22 23 24   22 23 24 25 26 27 28
27 28 29 30            25 26 27 28 29 30 31   29 30
        July                  August                September
Su Mo Tu We Th Fr Sa   Su Mo Tu We Th Fr Sa   Su Mo Tu We Th Fr Sa
       1  2  3  4  5                   1  2       1  2  3  4  5  6
 6  7  8  9 10 11 12    3  4  5  6  7  8  9    7  8  9 10 11 12 13
13 14 15 16 17 18 19   10 11 12 13 14 15 16   14 15 16 17 18 19 20
20 21 22 23 24 25 26   17 18 19 20 21 22 23   21 22 23 24 25 26 27
27 28 29 30 31         24 25 26 27 28 29 30   28 29 30
                       31
       October               November               December
Su Mo Tu We Th Fr Sa   Su Mo Tu We Th Fr Sa   Su Mo Tu We Th Fr Sa
          1  2  3  4                      1       1  2  3  4  5  6
 5  6  7  8  9 10 11    2  3  4  5  6  7  8    7  8  9 10 11 12 13
12 13 14 15 16 17 18    9 10 11 12 13 14 15   14 15 16 17 18 19 20
19 20 21 22 23 24 25   16 17 18 19 20 21 22   21 22 23 24 25 26 27
26 27 28 29 30 31      23 24 25 26 27 28 29   28 29 30 31
                       30

Print calendar for particular month and year

Use syntax as follows:
cal {month [1-12]} {year[1-9999]}
For example, display Jan-2007 calendar, enter:
$ cal 1 2007

Print the previous month

To print the previous month, the current month, and the next month all on one row, enter:
$ cal -3

Display Julian Calendar, if combined with the -e option, display date of easter according to the Julian Calendar.

$ cal -J

Display date of easter (for western churches)

$ cal -e

Print a calendar where Monday is the first day of the week, as opposed to Sunday.

$ cal -m

Display Julian days (days one-based, numbered from January 1).

$ cal -j

Display date of orthodox easter (Greek and Russian Orthodox Churches).

$ cal -o
Print the country codes and switching days from Julian to Gregorian Calendar as they are assumed by ncal. The country code as determined from the local environment is marked with an asterisk.
$ cal -p

Print the number of the week below each week column.

cal -w

Display a calendar for the current year.

$ cal -y

TwitterFacebookGoogle+PDF versionFound an error/typo on this page? Help us!

{ 7 comments… read them below or add one }

1 bob December 6, 2009 at 6:49 pm

I dont see some of those flags in my version of cal, I am running Fedora 12 with cal from util-linux-ng 2.16

Is it GNU gcal?

Reply

2 kiran January 19, 2012 at 8:34 am

how to display 3 different months in a year using cal in linux?

Reply

3 i am March 3, 2012 at 1:36 pm

how to display the easater date for 100 years ??
thanx

Reply

4 tom April 10, 2012 at 11:58 am

How to use cal -s
to check when did Spain switched from the Julian to Gregorian. Can you list the detailed country codes for cal -s

Reply

5 vikram mundotia October 22, 2012 at 7:36 pm

how to display to display two month together using cal commend in linux

Reply

6 Satya Prakash January 4, 2013 at 6:47 am

If it is prev, current and next months then you can use $cal -3

Reply

7 satish July 30, 2013 at 8:42 am

ncal -w 2013 output is different than the original week numbers. there is a shift of 1 week as per ncal -w 2013 as because week 1 of 2013 comes as week 53 .

Reply

Leave a Comment

Tagged as: , , ,

Previous Faq:

Next Faq: