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
How will you copy a file from one machine to other?
How do I open the shell in cmd?
What is console line?
What is web script?
What is the purpose of scripting?
What is a batch file used for?
I want to monitor a continuously updating log file, what command can be used to most efficiently achieve this?
Explain about "s" permission bit in a file?
How to get the 3rd element/column from each line from a file?
Write down the syntax for all the loops in shell scripting.
What is the default shell of solaris?
What are the zombie processes?
What is eval in shell script?
What is the best scripting language?
How do you find out What is your shell?