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


Click here to return to the 'View upcoming events on multiple Unix calendars' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
View upcoming events on multiple Unix calendars
Authored by: kenahoo on May 15, '06 10:39:57AM

That's a nice hint - I do have to point out the UUOC, though; you can simplify the command to this:

grep -h `date +"%m/%d"` /usr/share/calendar/ca*

-Ken



[ Reply to This | # ]
The Ruby version
Authored by: Lectrick on May 15, '06 12:25:43PM
I made this a Ruby script to iterate through the next 7 days of holidays. (Strangely, Memorial Day is not listed??) Save as something like "calendar.rb" and make executable (chmod +x calendar.rb) and run... The reason I commented out the alternate "date" code is because I wanted a solution that didn't depend on any include/requires (even though "date" is part of the standard lib...)

#!/usr/bin/env ruby
#require 'date'
#command = "Date.today.upto(Date.today+7){|d| p d.strftime("%m/%d")}

calendars = [ "christian", "computer", "history", "usholiday" ]

0.upto(7) { |d|
for cal in calendars do
out = `grep -h "#{(Time.now+(3600*24*d)).strftime("%m/%d")}" /usr/share/calendar/calendar.#{cal}`
puts out unless out == ""
end
}

---
In /dev/null, no one can hear you scream

[ Reply to This | # ]