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

Longest Substring Without Repeating Characters Java Program - The Coding Shala

Anti Diagonals - The Coding Shala

First Missing Positive Solution - The Coding Shala

Shell Script to Display the digits which are at odd positions in a given 5-digit number - The Coding Shala

Java Program to Convert Binary to Decimal - The Coding Shala