Search notes:

Display calendars with the shell command cal

cal can be used to display calendars in a shell. With no arguments, it shows the current month.

Show a specific month

Show the calendar for April 2018:
$ cal 2018 -m 4
2018-08-25: Apparently, this is not true for all versions of cal. Other versions seem to require month and year as arguments:
$ cal 4 2018

Show current and next two months

$ cal -A 2
Similarly, -B n can be used to show the preceding n months.
2018-08-25: Apparently, this is not true for all versions of cal. Other versions seem to require -n 4 to display current and following three months.

Show 5 months after a specific month

To print the months from November 2018 through March 2019, cal needs to be given the starting month and count of months:
$ cal 11 2018 -n 5

Show 5 months around a specific month

-S allows to indicate a month and a year around which the month-calendars should be printed.
The following command prints the calendar for November 2018.
$ cal -S 11 2018
If combined with -n 5, it prints the 5 months «around» November 2018, that is Septemper 2018 trhough January 2019.
$ cal -S 11 2018 -n 5

Show previous, current and next month

When executed on the December 13, 2017, cal -3 will print
$ cal -3
   November 2017         Dezember 2017          Januar 2018       
So Mo Di Mi Do Fr Sa  So Mo Di Mi Do Fr Sa  So Mo Di Mi Do Fr Sa  
          1  2  3  4                  1  2      1  2  3  4  5  6  
 5  6  7  8  9 10 11   3  4  5  6  7  8  9   7  8  9 10 11 12 13  
12 13 14 15 16 17 18  10 11 12 13 14 15 16  14 15 16 17 18 19 20  
19 20 21 22 23 24 25  17 18 19 20 21 22 23  21 22 23 24 25 26 27  
26 27 28 29 30        24 25 26 27 28 29 30  28 29 30 31           
                      31                                          

See also

ncal
The Python standard library calendar.
Shell commands

Index