If you're like me and you tend to forget what day it is
calendar like the one that
prints doesn't help much.
Here's a little shell script below that puts angle brackets around the current
For example, if today is August 7, 1996:
calAugust 1996 S M Tu W Th F S 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
If you're sure that this script will never be called by another program that expects the system version, you can name this cal, too - just be sure to put it in a directory, the system location of most versions of cal. Otherwise, give the script another name, such as cal_today.
The script puts the output of date into its command-line parameters;
it adds an
x first for safety (in case the date command
doesn't make any output, the set command will still have arguments
and won't output a list of all shell variables).
The parameters look like this:
x Wed Aug 7 20:04:04 PDT 1996
and the fourth parameter, in
$4, is what the script uses:
If you give any arguments, the script assumes that you don't want the
current month; it runs the system cal command.
Otherwise, the script pipes the system cal output into
> < at the start of a line.
Then it uses two substitute commands - one for the beginning or middle,
the other for the end of a line - one is guaranteed to match the current date.