Calendar (cal) on Linux command line

terminal-logo-smallSometimes it feels that many of the excellent and convenient command-line tools is forgotten, when they are replaced by graphical tools. A good example is the cal program, which is a command-line calendar to Linux and UNIX. It displays a simple calendar in text format.


Cal usage:

Displays current month calendar on console:

cal

Output:

 October 2009 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

Displays selected month and year calendar on console:

cal 11 2012

Output:

 November 2012 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

Displays selected day, month and year calendar on console, also highlight day:

cal 21 11 2010

Output:

 November 2010 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

cal with -m option display Monday as the first day of the week:

cal -m 4 2011

Output:

 April 2011 Mo Tu We Th Fr Sa Su 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

cal with -j option display days numbered from January 1:

cal -j 24 4 2011

Output:

 April 2011 Sun Mon Tue Wed Thu Fri Sat 91 92 93 94 95 96 97 98 99
100 101 102 103 104 105 106
107 108 109 110 111 112 113
114 115 116 117 118 119 120

cal with -3 option display prev/current/next month output:

cal -3 -m 21 11 2009

Output:

 October 2009 November 2009 December 2009 Mo Tu We Th Fr Sa Su Mo Tu We Th Fr Sa Su Mo Tu We Th Fr Sa Su 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 

cal with -j option display a calendar for the whole year:

cal -y 2010

Output:

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

And all of these options can be combined with the desired way, such as:

cal -3 -m -j 24 12 2009

Output:

 November 2009 December 2009 January 2010 Mon Tue Wed Thu Fri Sat Sun Mon Tue Wed Thu Fri Sat Sun Mon Tue Wed Thu Fri Sat Sun 305 335 336 337 338 339 340 1 2 3
306 307 308 309 310 311 312 341 342 343 344 345 346 347 4 5 6 7 8 9 10
313 314 315 316 317 318 319 348 349 350 351 352 353 354 11 12 13 14 15 16 17
320 321 322 323 324 325 326 355 356 357 358 359 360 361 18 19 20 21 22 23 24
327 328 329 330 331 332 333 362 363 364 365 25 26 27 28 29 30 31
334 

Posted by Web Monkey