Shell script to display the message Good Morning/Good afternoon /Good Evening depending on the time

Aim: Write a shell script which whenever gets executed displays the message Good Morning/Good afternoon /Good Evening depending on the time it gets executed

#!/bin/bash
hour=`date +%I`
min=`date +%M`
ampm=`date +%p`
echo "$hour : $min $ampm"
if [ $ampm="AM" ]
then
echo "Good Morning"
else
if [ $hour -eq 12 -o $hour -lt 4]
then
echo "Good afternoon"
elif [ $hour -ge 4 -a $hour -le 8 ]
then
echo "Good evening"
fi
fi
Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments