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

Answer Posted / vipul dalwala

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"

Is This Answer Correct ?    13 Yes 15 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is $1 in shell scripting?

724


What is a shell script? Can you name some of its advantages?

632


Set up a Sev 2 alert when the Primary WA service fails. A windows batch script needs to be created that will monitor the WA service on the Primary and when the service stops/fails a Sev 2 TT is generated for a particular team ?

1823


What is the difference between grep and egrep?

713


Is scripting and coding the same thing?

677






What is the conditional statement in shell scripting?

783


How will you emulate wc –l using awk?

1095


What is the equivalent of a file shortcut that we have a window on a linux system?

724


What is basename in shell script?

711


What does it mean to debug a script?

694


How do I run a bin bash script?

691


What is meant by $1 in shell script?

662


What are zombie processes?

675


How does ls command work?

716


is this growing field and what is average package in this?

1993