Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

write a shell script to find the largest number from 3 given
numbers.

Answer Posted / aseem

Hi

"In continuation to above answer.

If you want to write a script in more generic way.

if [ $# -eq 0 ]
then
echo "$0: numbers are not given" >&2
exit 1
fi
LARGEST=$(echo $* | xargs -n1 | sort -nr | tail -1)
echo "$LARGEST is largest number""

The above script is good but there is a small msitake. As
numeric sort is used in reverse order so the biggest number
will come first, so we should use head -1 rather than tail -
1

Is This Answer Correct ?    9 Yes 8 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

How can I set the default rwx permission to all users on every file which is created in the current shell?

1371


Given a file find the count of lines containing the word "abc".

1491


Explain about debugging?

965


What is console line?

921


What is shell environment?

916


How will you emulate wc –l using awk?

1463


What is basename in shell script?

1009


Is shell a part of kernel?

1000


Is powershell a language?

982


What are "c" and "b" permission fields of a file?

970


How to get the last line from a file using just the terminal?

1148


Explain about login shell?

1055


What does echo mean in scripting?

954


What is a shell script in windows?

1022


How can the contents of a file inside jar be read without extracting in a shell script?

1080