Thursday, June 21, 2018

Write a shell script that greets the user by saying Good Morning, Good Afternoon, and Good Evening according to the system time. - OS

#hours=`date|cut -c 12-13`
hours=`date +%H`
if [ $hours -le 12 ]
then
echo "Good Morning"
elif [ $hours -le 16 ]
then
echo "Good Afternoon"
elif [ $hours -le 20 ]
then
echo "Good Evening"
else
echo "Good Night"
fi

No comments:

Post a Comment