Sunday 10 August 2014

Write a shell script that gets executed displays the message either “Good Morning” or “Good Afternoon” or “Good Evening” depending upon time at which the user logs in.


echo "Greetings of the day"
echo `date`
h=`date |cut -c 12-13`
if [ $h -ge 0 -a $h -lt 12 ]
then
echo "Good Morning"
elif [ $h -ge 12 -a $h -lt 18 ]
then
echo "Good Afternoon"
elif [ $h -ge 18 -a $h -lt 20 ]
then
echo "Good Evening"
else
echo "Good Night"
fi

0 comments:

Post a Comment

 
- |