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

Time Complexity, Space Complexity, Asymptotic Notations - The Coding Shala

LeetCode - Crawler Log Folder Solution - The Coding Shala

Graph Representation using Adjacency Matrix - The Coding Shala

Java Method Overloading - The Coding Shala

Client-Server Java Program (Socket Programming) - The Coding Shala