Code In Tech - The Ultimate World of Computer Technology

Monday 4 June 2012

Shell script to greet user according to time.

SOURCE CODE:

hr=`date "+ %H"`

echo "Hour : " $hr

if test $hr -lt 12

then

echo "Good Morning User "

elif test $hr -gt 16


then

echo "Good Evening User "

else

echo "Good Afternoon User "

fi

OUTPUT: 

Hour:11
Good morning user.

No comments :

Post a Comment