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 to get the 3rd element/column from each line from a file?

1180


What are the different types of shell scripting?

1104


What is meant by $1 in shell script?

948


What is shell geeksforgeeks?

1102


How many fields are present in a crontab file and what does each field specify?

1110


What is the crontab?

1073


What can you do with powershell?

1129


Is shell scripting a programming language?

1039


What is the syntax of while loop in shell scripting?

1041


How do we delete all blank lines in a file?

1105


How do you create a shortcut in linux?

1188


madhar chod unix ke 10 commands dhang se likh nahi sakta hai

3469


Is bash a shell script?

1055


what is tickets $ what low,medium,high priorite pls define time also

2146


What is an inode block?

1045