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 the best scripting language?
Where is bash history?
What is the meaning of $1 in shell script?
What is basename in shell script?
What is inside a seashell?
What are the different commands available to check the disk usage?
How to get the 3rd element/column from each line from a file?
How to get script name inside a script?
What is shell chemistry?
Is shell script a programming language?
In my bash shell I want my prompt to be of format '$"present working directory":"hostname"> and load a file containing a list of user-defined functions as soon as I log in, how will you automate this?
What is meant by $1 in shell script?
What is option in shell script?
What is shell application?
How do you know which shell I am using?