代码应该花一个小时作为输入,然后说早安、下午或晚上。当代码以 12 运行时,它说 if 语句语法错误,但它在 0 下运行良好。
#!/bin/csh
#
# Time of day greeting
#
# usage: greet [hour between 0-23]
#
if ($#argv == 0) then
set hour = 'date +%H'
else
set hour = $argv[1]
endif
#
if ($hour < 12) then
echo "Good Morning\!"
else
if (hour < 18) then
echo "Good Afternoon\!"
else
echo "Good Evening\!"
endif
endif
#
exit 0
#