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 Create a Simple Calculator - The Coding Shala

New Year Chaos Solution - The Coding Shala

Java Program to Convert Binary to Decimal - The Coding Shala

N-th Tribonacci Number Solution - The Coding Shala

Single Number 2 LeetCode Solution - The Coding Shala