Linux:: Time calendar command [3]: cal command: query the day of the year, output the current monthly calendar, specify the monthly calendar, output the current annual calendar, specify the annual calendar

Preface: This article is the content of the basic Linux operation chapter!
The environment I use is based on Tencent Cloud Server: CentOS 7.6 64bit.


Study set:


Directory index:
1. Basic understanding and syntax format and functions
2. Common options and basic usage
- - 2.1 Display the calendar of the current month
- - 2.2 "-y": output the calendar of a certain year
- - 2.3 "-j": get the current year Day
3. Recommended related articles or series


1. Basic understanding and grammatical format and functions

1.1 Basic understanding

The cal command can be used to display the Gregorian (solar) calendar. The Gregorian calendar is the calendar currently used internationally, also known as the Gregorian calendar and commonly known as the Gregorian calendar. The "Gregorian calendar" is also called the "Solar calendar", which is based on the earth's orbit around the sun as one year. It is common in Western countries, so it is also called the "Western calendar".

1.2 Grammar format and functions

Syntax format: cal [parameter] [year]


Function: Used to view calendar and other time information. If there is only one parameter, it represents the year (1-9999). If there are two parameters, it represents the month and year.


2. Common options and basic usage

2.1 Display the current month’s calendar

Syntax format: cal

Note: There is no need to add any additional information to display the current month format, just use the command directly!

[Mortal@VM-12-16-centos test_txtfile]$ cal
      May 2023      
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

2.2 "-y": Output the calendar of a certain year

Syntax format: cal -y year

year: indicates the specified year

[Mortal@VM-12-16-centos test_txtfile]$ cal -y 2023
                               2023                               

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

2.3 "-j": Get the day of the year it is now

Note: The number of days in the year is displayed (the date in a year is calculated in days, starting from January 1st, and the number of days in the current month in the year is displayed by default) [The current time point will be marked in the actual program]

[Mortal@VM-12-16-centos test_txtfile]$ cal -j
          May 2023         
Sun Mon Tue Wed Thu Fri Sat
    121 122 123 124 125 126
127 128 129 130 131 132 133
134 135 136 137 138 139 140
141 142 143 144 145 146 147
148 149 150 151

Insert image description here


3. Recommendations for related articles or series

1. Linux learning directory collection ;


2. Linux:: Time calendar command [1]: date command: formatted display of time information, acquisition of time under Linux
3. Linux:: time calendar command [2]: date command and timestamp (and the interaction between date and time stamp conversion)


Guess you like

Origin blog.csdn.net/weixin_53202576/article/details/131057249