# Shell script to read 3 numbers and find the greaters of the three

`#!/bin/bash# Shell script to read 3 numbers and find the greaters of the three# -------------------------------------------------------------------------# Copyright (c) 2005 nixCraft project <http://cyberciti.biz/fb/># This script is licensed under GNU GPL version 2.0 or above# -------------------------------------------------------------------------# This script is part of nixCraft shell script collection (NSSC)# Visit http://bash.cyberciti.biz/ for more information.# ----------------------------------------------------------------------echo -n "Please enter three numbers (separate number by space) : "read a b c# compare a with b and c. Note -a is logical and operatorif [ \$a -gt \$b -a \$a -gt \$c ]then   big=\$aelif  [ \$b -gt \$a -a \$b -gt \$c ] # compare b with a and cthen   big=\$belif  [ \$c -gt \$a -a \$c -gt \$b ] # compare c with a and bthen   big=\$celif [ \$a -eq \$b -a \$a -eq \$c -a \$b -eq \$c -a \$c -eq \$b ] # see if all of them are equal or notthen   big="All three numbers are same (equal)"else # something must be wrong if we are here, like one of number is character such as 'A'   big="Can not guess greaters of three numbers"fi# display result echo "Result : \$big"`

Comments on this entry are closed.

• SABAREESAN

thanks !!! helps 4 learning unix 4 begineers like me

• http://bash.cyberciti.biz sanjay kundu

the program length is very simple

• mayur

really simple…

• trilok

thanx for help us….

• Muthu Lakshmanan

I Like thisssssssssssssssss

• mahendra bohra

this is good because all steps are defined

• sameer mishra

superb logic

• hamza

i love it, cos am just learning shell