Linux For Cynics One user's experiences with Linux

6May/130

Simple Command Line Calendar

The cal program displays a simple calendar on the command line. Here are some examples of its use:

Invoking it with no arguments displays the current month.

$ cal

Output:

      May 2013        
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

To see a particular month, run it with like cal month year:

$ cal 12 2013

Output:

   December 2013      
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  

To see a whole year, run it with like cal year:

$ cal 2013

Or to display a 3 month period instead of just the current month, use the -3 flag:

$ cal -3

Output:

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

This flags can be combined.

Finally, use the ncal command instead of cal to display the calendar in a more space-efficient way:

$ ncal 12 2013

Output:

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

No comments yet.


Leave a comment


No trackbacks yet.