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
What does sh mean?
Write the syntax for "if" conditionals in linux?
What are the types of script?
How can we find the process name from its process id?
Give some situations where typing error can destroy a program?
What is the first line of a shell script called?
How do I debug a shell script?
What does $$ mean in shell script?
What is k shell?
Write down the syntax of "for " loop
How important is shell scripting?
What is shell chemistry?
Explain how you Automate your application using Shell scripting.
Explain about the exit command?
Explain about non-login shell files?