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 k shell?
What language is bash?
How do I run a powershell script?
How do I debug a shell script?
Calculate a real number calculation directly from the terminal and not any shell script.
What is the use of a shebang line?
What is wc in shell script?
Which shell is the best?
Print a given number, in reverse order using a shell script such that the input is provided using command line argument only.
What is the crontab?
How to find duplicate record in file using shell script?
What is the purpose of scripting?
Is shell script a programming language?
State the advantages of shell scripting?
Is shell a part of kernel?