Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!

Print off a calender for the year UNIX
To print off a yearly calendar, open the Terminal and type:
cal -y|open -f
This will display a full-year's calendar in TextEdit. Print the TextEdit document, and you're done.

This works in this manner: cal -y generates a yearly calendar and then its output (the calendar) is passed via the pipe (the | symbol) to open -f, which reads from standard input and makes a new TextEdit document.

Here's a bit of sample output:
                              2005                              

      January               February               March        
 S  M Tu  W Th  F  S   S  M Tu  W Th  F  S   S  M Tu  W Th  F  S
                   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
 etc. etc. etc.
[robg adds: Yes, this is a simple Unix hint. But not everyone's a wizard (myself definitely included!), and some may find this useful as a demonstration of sending terminal output to TextEdit. You might also want to add the j flag to the cal command, which will number the dates of the year sequentially. If you prefer the GUI of iCal, this hint offers some calendar printing tips...]
    •    
  • Currently 2.80 / 5
  You rated: 1 / 5 (5 votes cast)
 
[17,409 views]  

Print off a calender for the year | 5 comments | Create New Account
Click here to return to the 'Print off a calender for the year' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
Print off a calender for the year
Authored by: red6rick on Feb 09, '05 10:47:48AM
As a command line junkie (Hi, my name is Rick, and I've been typing for 30 years...), using a wonderful unix tool to produce output to move text into a GUI program to print seems to border on heresey. Instead, you should use the tool "enscript" which takes any text sent to it, or any plain text file specified on the command line, formats and prints it on the default printer. So the entire operation to print a calendar becomes:

cal -y | enscript
with no mouse involved.

[ Reply to This | # ]
Print off a calender for the year
Authored by: rcameron2003 on Feb 09, '05 10:54:09AM

This is SO cool! I love the simple stuff!



[ Reply to This | # ]
Print off a calender for the year
Authored by: TrumpetPower! on Feb 09, '05 02:44:07PM

Well, so long as we're on the topic of cal, you can do a couple other things, too. ``cal 1970'' will print the calendar for that year, and ``cal 4 1970'' will print just April of 1970.

enscript has lots of goodies in it, too, like multi-column formatting.

To read more about either: ``man cal'' or ``man enscript'' in Terminal will tell you the whole story.

Cheers,

b&



[ Reply to This | # ]
Print off a calender for the year
Authored by: StarvArt on Feb 09, '05 04:40:43PM

I've been using (in Terminal.app):

        cal {args} | pbcopy

which copies it to the clipboard for me to paste anywhere I like for further processing or printing.

[ Reply to This | # ]

Print off a calender for the year
Authored by: swanksalot on Feb 09, '05 08:52:32PM
You can eliminate sending to TextEdit by typing, for instance,
 cal 1969 | lpr
 
as long as you have a printer already selected, of course.

[ Reply to This | # ]