📜  cal (1)

📅  最后修改于: 2023-12-03 14:40:00.850000             🧑  作者: Mango

Introduction to 'cal'

The cal command is a useful tool for programmers and system administrators working with the command line interface in Unix-like operating systems. It is used to display a calendar for a specified month or year.

Usage

The basic syntax for cal command is as follows:

cal [options] [month] [year]
Options

Some commonly used options with cal command are:

  • -3 or --three : Display the previous, current, and next month.
  • -1 or --one : Display only the current month.
  • -j or --julian : Display Julian calendar instead of Gregorian calendar.
  • -y or --year : Display a calendar for the given year.
Examples
  1. Display the calendar for the current month:
cal

Output:

     October 2022
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
  1. Display the calendar for a specific month:
cal 12 2022

Output:

   December 2022
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
  1. Display the calendar for a specific year:
cal -y 2022

Output:

                            2022

      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         1  2  3  4  5         1  2  3  4  5
 2  3  4  5  6  7  8   6  7  8  9 10 11 12   6  7  8  9 10 11 12
 9 10 11 12 13 14 15  13 14 15 16 17 18 19  13 14 15 16 17 18 19
16 17 18 19 20 21 22  20 21 22 23 24 25 26  20 21 22 23 24 25 26
23 24 25 26 27 28 29  27 28                 27 28 29 30 31      
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   1  2  3  4  5  6  7         1  2  3  4  5
 3  4  5  6  7  8  9   8  9 10 11 12 13 14   6  7  8  9 10 11 12
10 11 12 13 14 15 16  15 16 17 18 19 20 21  13 14 15 16 17 18 19
17 18 19 20 21 22 23  22 23 24 25 26 27 28  20 21 22 23 24 25 26
24 25 26 27 28 29 30  29 30 31              27 28 29 30      
...

These are just a few examples of how the cal command can be used. It provides a quick and easy way to view calendars directly from the command line interface.

For more details and options, refer to the cal command's manual page by running man cal in the terminal.