If you type the command calendar, you'll see lines with "to-do" items for today and tomorrow from a file named calendar in your current directory. If you put that file in your home directory, your system administrator can run the command calendar-to everyones' "to-do" items to them. You can also automate your personal calendar setup by running calendar yourself - the calendar can be mailed to you, sent to the printer, and so on, first thing each morning. See below for an example calendar file and more information.
calendar builds a complicatedexpression to search your calendar file. You can see that expression yourself if you want to.
Let's start by showing a few lines of a sample calendar file. (Yours can be much longer.) Then I'll run calendar to show what lines it picks:
cat calendar-- WORK -- 12/28 Project report due tomorrow! -- PERSONAL -- * 8 rub Lisa's feet Take Lisa out to dinner on December 8 dec 9 buy Lisa lunch On 12/10, Lisa will be hungry for ice cream -- BIRTHDAYS -- 1/1 Mom's birthday - make dinner reservations by 12/20! %
dateTue Dec 8 08:43:40 PST 1992 %
calendar* 8 rub Lisa's feet Take Lisa out to dinner on December 8 dec 9 buy Lisa lunch
Today is December 8.
The calendar utility found lines in my calendar file for
today and tomorrow.
calendar understands lots of date formats.
The date can be anywhere on a line.
If you leave a line in your file for more than one year (like Mom's
birthday) calendar will show it every year.
If a line has more than one date, you'll see the line on both of those
dates (I'll be reminded before Mom's birthday and also in time to make a
An asterisk (
*) in place of a month means "all months."
Many versions of calendar utility run your calendar file
through the C language preprocessor, cpp.
Among other things, this lets you include
several calendar files in your own calendar file.
Lines that start with a hash mark (
#) in column 1 are read by the
For instance, this line in your calendar file would include all
the contents of the file /usr/local/lib/office.calendar
just as if you'd typed them into your own file:
Someone (the office secretary) can maintain the office.calendar file.
People in the office who want reminders from it can put the
#include line in their own calendar files.
By the way, if you start a line with
# and it's not for the
preprocessor, you'll get a mysterious error like
That means line 1 of the file had something the preprocessor couldn't
How can calendar find dates in all the formats it accepts - and
only for today and tomorrow?
It runs a system program, usually named /usr/lib/calendar,
that generates an expression for
T; spaces are shown as .
I'll turn the first line of that into English.
I'm not writing this just for egrep fanatics
:-); this is
also useful for understanding what kinds of dates calendar will
I'm going to skip some not-so-subtle things like the nesting of the parentheses
and just give an overview.
If you haven't seen extended regular expressions before, see article
The expression finds lines in your calendar file that meet these
conditions, in order from left to right across the line:
This matches whatever comes before the date.
Match at the beginning of a line (
^) or (
a space, TAB, opening parenthesis, comma, or semicolon
This keeps egrep from matching other words that start with or
contain the month abbreviation
This matches the date.
Match Dec or dec with zero or more of any character besides
space or TAB after
|) have a literal asterisk
\*), which means "match this on any month of the year."
|) match a numeric month like 012 or 12 or a literal
(012|12|\*))-followed by a slash (
Finally, you need today's date: it starts with any number of
zeros and ends with 8 (
The end of the expression matches lines anything except a digit - or matches the end of the line. This keeps egrep from matching non-dates like 8.75.
Whew. That expression is repeated for every other day that needs to be matched. On Fridays, the output of /usr/lib/calendar has four lines - one each for Friday, Saturday, Sunday, and Monday.
If you want a calendar every weekday, put a line like the following into your. We've split this onto two lines for printing, but you should type it all on one line:
That runs calendar from my home directory at
line Calendar for today to the message.
It isn't required.)
Finally, the temporary file is removed.