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 the best scripting language?

1021


Where is bash history?

913


What is the meaning of $1 in shell script?

1112


What is basename in shell script?

1052


What is inside a seashell?

1130


What are the different commands available to check the disk usage?

995


How to get the 3rd element/column from each line from a file?

1180


How to get script name inside a script?

1001


What is shell chemistry?

972


Is shell script a programming language?

1023


In my bash shell I want my prompt to be of format '$"present working directory":"hostname"> and load a file containing a list of user-defined functions as soon as I log in, how will you automate this?

1137


What is meant by $1 in shell script?

948


What is option in shell script?

1011


What is shell application?

984


How do you know which shell I am using?

1039