Monday, 27 May 2013

Shell Script to find time of day

time=$(date +%T)
hh=`echo $time | cut -b 1-2`
mm=`echo $time | cut -b 4-5`
if [ $hh -ge 5 ] && [ $hh -le 12 ]
then
    echo "Good Morning"
else
    echo "Good Afternoon"
fi

No comments:

Post a Comment