Program No.4.B
Write a shell script that displays “Good morning”, “Good afternoon” or “Good evening”, depending upon the time at which the user logs in.
Solution:
echo "Greeting of the day."
x=`date | cut -c 12-13`
echo $x
y=`date | cut -c 12-16`
echo $y
if [ $x -ge 0 ] && [ $x -lt 10 ]
then
echo "Good morning."
elif [ $x -ge 10 ] && [ $x -lt 14 ]
then
echo "Good afternoon."
elif [ $x -ge 14 ] && [ $x -lt 20 ]
then
echo "Good evening."
else
echo "Good night."
fi
Write a shell script that displays “Good morning”, “Good afternoon” or “Good evening”, depending upon the time at which the user logs in.
Solution:
echo "Greeting of the day."
x=`date | cut -c 12-13`
echo $x
y=`date | cut -c 12-16`
echo $y
if [ $x -ge 0 ] && [ $x -lt 10 ]
then
echo "Good morning."
elif [ $x -ge 10 ] && [ $x -lt 14 ]
then
echo "Good afternoon."
elif [ $x -ge 14 ] && [ $x -lt 20 ]
then
echo "Good evening."
else
echo "Good night."
fi
0 comments:
Post a Comment