Write a shell script to get your name and greet you depending on time

Write a shell script to get your name and greet you depending on time

Code:

clear
echo -------------------------------------------------
echo '\tGreeting user depending upon time'
echo -------------------------------------------------
echo Enter your name
read name
d=$(date '+%H')
echo " "
if [ $d -gt 1 ] && [ $d -lt 12 ]
then
echo Good Morning $name
elif [ $d -ge 12 ] &&  [ $d -lt 15 ]
then
echo Good Afternoon $name
else
echo Good Evening $name
fi

Output:

------------------------------------------------- 
Greeting user depending upon time 
------------------------------------------------- 
Enter your name 
Satheesh 

Good Morning Satheesh

No comments

Powered by Blogger.