Shell Script To Find Out Biggest Number Form Given Three Numbers - The Coding Shala

Home >> Scripting >> Biggest number

Shell Script To Find Out Biggest Number Form Given Three Numbers

Write a shell script to find out the biggest number form given three numbers. Numbers are supplied by the command line argument?

Code: 

#!/bin/bash
if [ $# -ne 3 ] 
then
echo "enter three argument"
exit 1
fi

if [ $1 -gt $2 ] && [ $1 -gt $3 ] 
then
echo "$1 is biggest number"
elif [ $2 -gt $1 ] && [ $2 -gt $3 ]
then
echo "$2 is the biggest number"
elif [ $3 -gt $1 ] && [ $3 -gt $2 ]
then
echo "$3 is biggest number"
else
echo "all numbers are equal"
fi



Other Posts You May Like
Please leave a comment below if you like this post or found some error, it will help me to improve my content.

Comments

Popular Posts from this Blog

Shell Script to find sum, product and average of given numbers - The Coding Shala

Shell Script to Create a Simple Calculator - The Coding Shala

Add two numbers in Scala - The Coding Shala

New Year Chaos Solution - The Coding Shala

Richest Customer Wealth LeetCode Solution - The Coding Shala