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

Explain about echo command?

1046


Is shell and terminal the same?

993


What language is used in terminal?

937


What makes c shell a more preferable option than the bourne shell?

913


What is shell terminal?

901


What lives in a shell?

893


Is shell a part of kernel?

1000


What are the different variables present in linux shell?

1042


What is a boot block?

962


What are filters explain sort with all the options available?

1280


What are the zombie processes?

918


What language is shell scripting?

971


What is the use of echo in shell script?

952


What is option in shell script?

956


How do I open the shell in cmd?

1047