Read the rest of the article for the script and an explanation as to how it works.
Here is the script:
#!/bin/tcsh(The last "echo" command is on all one line)
set tod='morning'
set hour=`date | cut -c 12-13`
if ($hour > 11) then
set tod='afternoon'
endif
if ($hour > 17) then
set tod='evening'
endif
echo "Good" $tod "and welcome to Darwin." > /Private/etc/motd
The way this works is to initially set a variable to "morning". It then sets a variable to the results of running date to get the current date and time. This is piped to cut which selects characters 12 and 13 which correspond to the hour (in 24-hour format). The open single quote characters around the statement means that its contents will be evaluated before the assignment is made, which is a very useful tool in shell scripting. The hour is then compared against 11 to see if the time is 12 or later. If so, the time of day string is changed to "afternoon". If the time is greater than 17 (6 pm or later), the string is changed to "evening". This is then echoed out and redirected to the file /Private/etc/motd.
When this runs next, the motd file will be set according to the time of day and the next time you open a terminal window, the welcoming message will be appropriate to the time of day.
Of course, if your machine doesn't run all the time, the cron task may not have run, but there are other tools available to solve this problem.
[Editor's note: I have not tried this script myself.]

