Subscribe to Get Free Material Updates!
Visit my new blog WebData Scraping - Web Scraping Service provider company in India.

Write a script to display the date, time and a welcome message (like Good Morning etc.). The time should be displayed with “a.m.” or “p.m.” and not in 24 hours notation.


clear
HH=`date +%H`
time=`date +"%S %p"`
if [ $HH -ge 12 ];then
 HH=`expr $HH % 12`
 if [ $HH -lt 5 ];then
  msg="GOOD AFTERNOON"
 elif [ $HH -ge 5 ]  &&  [ $HH -lt 9 ];then
  msg="GOOD EVENING"
 else
  msg="GOOD NIGHT"
 fi
 echo "$msg ,CURRENT TIME $HH:$time"
 exit 1
else
 if [ $HH -lt 5 ];then
  msg="GOOD NIGHT"
 else
  msg="GOOD MORNING"
 fi
 echo "$msg ,CURRENT TIME $HH:$time"
 exit 1
fi

Output: 

0 comments:

Post a Comment

Related Posts Plugin for WordPress, Blogger...

 
Design by Wordpress Theme | Bloggerized by Free Blogger Templates | coupon codes