-->

Shell Script to find the greatest of three number provided as command line arguments

Posted by Admin on
Write Script to find out biggest number from given three nos. Nos are supplies as command line argument. Print error if sufficient arguments are not supplied.


#!/bin/ksh

# check if we have less than three argument , if yes them exit from here 
if [ $# -ne 3 ]
then
echo "Please give 3 command line argumnets"
exit 1;
fi

if [ $1 -gt $2 ] && [ $1 -gt $3 ]
then
echo " $1 is the greatest number "
elif [ $2 -gt $3 ] && [ $2 -gt $1 ]
then
echo " $2 is the greatest number "
else
echo "$3 is the greates number"
fi


No comments:

Post a Comment