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


Please Help Members By Posting Answers For Below Questions

How will you copy a file from one machine to other?

674


How do I open the shell in cmd?

662


What is console line?

688


What is web script?

696


What is the purpose of scripting?

686






What is a batch file used for?

689


I want to monitor a continuously updating log file, what command can be used to most efficiently achieve this?

889


Explain about "s" permission bit in a file?

715


How to get the 3rd element/column from each line from a file?

823


Write down the syntax for all the loops in shell scripting.

788


What is the default shell of solaris?

691


What are the zombie processes?

672


What is eval in shell script?

787


What is the best scripting language?

688


How do you find out What is your shell?

707