Calendaring with cal

One of the handiest UNIX utilities is cal, which—logically—is a calendar. Find out what today's date is, what day of the week December 31st is, or what the calendar year looks like. As Code Listing 15.1 shows, all you have to do is type cal and any specific options you want.

To use the calendar utility:

1.
cal

Type cal at the shell prompt to see the current month's calendar, as shown in Code Listing 15.1. Then, start playing with options, as shown in the next few steps.

2.
cal -j

Use cal -j to see the Julian calendar, which shows each day numbered from the beginning of the year.

3.
cal 1999 | more

Pipe cal 1999 to more to see the whole year's calendar.

4.
cal 12 1941

Type cal plus specific dates to view dates for a particular year.

Tip

Note that cal is Y2K compliant. If you ask for cal 98, you'll get the calendar for the year 98. That is, 1900 years ago.


Tip

Put cal into your startup configuration files to get a reminder of the date whenever you log in. Check out Chapter 8 for details.


Code Listing 15.1. Just type cal to see the current month's calendar, or check out other calendar options with flags.
[ejr@hobbes ch15]$ cal
August 1998
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
[ejr@hobbes ch15]$ cal -j
        August 1998
Sun Mon Tue Wed Thu Fri Sat
                       213
214 215 216 217 218 219 220
221 222 223 224 225 226 227
228 229 230 231 232 233 234
235 236 237 238 239 240 241
242 243
[ejr@hobbes ch15]$ cal 1999 | more
                                 1999
       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        1  2  3  4  5  6        1  2  3  4  5  6
3  4  5  6  7  8  9     7  8  9  10 11 12 13    7  8  9  10 11 12 13
10 11 12 13 14 15 16   14  15 16 17 18 19 20    14 15 16 17 18 19 20
17 18 19 20 21 22 23   21  22 23 24 25 26 27    21 22 23 24 25 26 27
24 25 26 27 28 29 30   28                       28 29 30 31
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  3                       1           1 2 3 4  5
4  5  6  7  8  9  10   2  3  4  5  6  7   8   6  7  8  9 10 11 12
11 12 13 14 15 16 17   9 10 11 12 13 14 15   13 14 15 16 17 18 19
18 19 20 21 22 23 24   16 17 18 19 20 21 22  20 21 22 23 24 25 26
25 26 27 28 29 30      23 24 25 26 27 28 29  27 28 29 30
                      30 31
        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  2  3    1  2  3  4  5  6  7             1  2  3  4
4  5  6  7  8  9  10   8 9  10 11 12 13 14     5  6  7 8  9  10 11
11 12 13 14 15 16 17  15 16 17 18 19 20 21     12 13 14 15 16 17 18
18 19 20 21 22 23 24  22 23 24 25 26 27 28    19 20 21 22 23 24 25
25 26 27 28 29 30 31  29 30 31        26 27 28 29 30
       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      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
[ejr@hobbes ch15]$ cal 12 1941
December 1941
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
[ejr@hobbes ch15]$

Code Listing 15.2. The system presents you with the reminder on command.
xmission> calendar
august 28 On this date in history, nothing
   special happened. We think.
xmission>

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.133.138.177