Open the text file via terminal
sudo gedit laint.sh
Copy and paste the following lines
#!/bin/bash
# Shell code to find largest integer among the 3 integers given as arguments.
# -------------------------------------------------------------------------
a=$1
b=$2
c=$3
if [ $# -lt 3 ]
then
echo "$0 n1 n2 n3 "
exit 1
fi
if [ $a -gt $b -a $a -gt $c ]
then
echo "$a is largest integer"
elif [ $b -gt $a -a $b -gt $c ]
then
echo "$b is largest integer"
elif [ $c -gt $a -a $c -gt $b ];
then
echo "$c is largest integer"
else
echo "Sorry cannot guess number"
fi
Save and exit from the file. Next
sudo chmod +x laint.sh
./laint.sh 90 70 40
the output is
90 is largest number
![](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEijTiLZBg2DSqWKPwl9mH5n6zOhgpFuxBveKaJLQSXVKDkNp216ViiHXUVyGB9mrjzul-WnGUePfpGCrlVH1eYCtdyvox6k2OKbpAXZyejRvYawh23u5PGX6f_kvl_HDDnGAD27w7lCIvc/s320/Selection_008.png)
0 comments:
Post a Comment