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
What is the default shell of solaris?
one folder contains lot of students name but I want to fetch hello with every student name individually using shell script
What is awk in shell script?
Which shell is the best?
What is shell chemistry?
What are the zombie processes?
What is $1 in shell scripting?
Why is used in shell scripting?
What are the types of script?
What is the conditional statement in shell scripting?
How do you know which shell I am using?
How do you debug a script?
What is a shell script in windows?
What is path in shell script?
What is shell and shell script?