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 / md. imran

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

or if you want to take input from a file so type following
cat <filename>|xargs -n1|sort|head -1


Note : In first scipt mistake was in tail -1
right answer is head -1 which i have mentioned there.

thanks

Is This Answer Correct ?    5 Yes 5 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is k shell?

904


What language is bash?

862


How do I run a powershell script?

1065


How do I debug a shell script?

1035


Calculate a real number calculation directly from the terminal and not any shell script.

1166


What is the use of a shebang line?

1129


What is wc in shell script?

943


Which shell is the best?

945


Print a given number, in reverse order using a shell script such that the input is provided using command line argument only.

1116


What is the crontab?

1020


How to find duplicate record in file using shell script?

1338


What is the purpose of scripting?

1023


Is shell script a programming language?

985


State the advantages of shell scripting?

1019


Is shell a part of kernel?

1013