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 is bourne shell scripting?
Where are cowrie shells found?
What is shell terminal?
What does $$ mean in shell script?
What is the significance of the shebang line in shell scripting?
What is a boot block?
What is the fastest scripting language?
Explain about debugging?
Is powershell a bash?
How does ls command work?
What can scripts do?
How do I debug a shell script?
What are the various stages of a linux process it passes through?
How will you print the login names of all users on a system?
What is sudo command?