hr=`date | cut -c 12-13`
if [ $hr -lt 12 ]
then
echo "Good Morning"
else
if [ $hr -ge 12 -a $hr -lt 15 ]
then
echo "Good Afternoon"
else
if [ $hr -ge 15 -a $hr -lt 24 ]
then
echo "Good Evening"
fi
fi
fi
Out put:
[csuser@localhost ~]$ vi tt
[csuser@localhost ~]$ chmod 777 tt (tt is a file name)
[csuser@localhost ~]$ ./tt
good morning
if [ $hr -lt 12 ]
then
echo "Good Morning"
else
if [ $hr -ge 12 -a $hr -lt 15 ]
then
echo "Good Afternoon"
else
if [ $hr -ge 15 -a $hr -lt 24 ]
then
echo "Good Evening"
fi
fi
fi
Out put:
[csuser@localhost ~]$ vi tt
[csuser@localhost ~]$ chmod 777 tt (tt is a file name)
[csuser@localhost ~]$ ./tt
good morning
No comments:
Post a Comment