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
Explain about echo command?
Is shell and terminal the same?
What language is used in terminal?
What makes c shell a more preferable option than the bourne shell?
What is shell terminal?
What lives in a shell?
Is shell a part of kernel?
What are the different variables present in linux shell?
What is a boot block?
What are filters explain sort with all the options available?
What are the zombie processes?
What language is shell scripting?
What is the use of echo in shell script?
What is option in shell script?
How do I open the shell in cmd?