• Source
    1. #
    2. #Write a script to display the date, time and a welcome message (like Good Morning etc.). The time
    3. #should be displayed with “a.m.” or “p.m.” and not in 24 hours notation.
    4. #
    5. clear
    6. echo "Welcome , "$(who m i | tr -s " " |cut -d " " -f1)
    7. hour=$(date +"%H")
    8. if [ $hour -gt 0 -a $hour -le 12 ]
    9. then
    10. echo "Good Morning"
    11. elif [ $hour -gt 12 -a $hour -le 17 ]
    12. then
    13. echo "Good afternoon"
    14. elif [ $hour -gt 17 -a $hour -le 19 ]
    15. then
    16. echo "Good evening"
    17. elif [ $hour -gt 19 -a $hour -le 24 ]
    18. then
    19. echo "Good night"
    20. fi
    21. echo "Date :"$(date +"%d/%m/%Y")
    22. echo "Time :"$(date +"%r")