write a shell script to find the largest number from 3 given
numbers.

Answer Posted / vipul dalwala

In continuation to above answer.

If you want to write a script in more generic way.

if [ $# -eq 0 ]
then
echo "$0: numbers are not given" >&2
exit 1
fi
LARGEST=$(echo $* | xargs -n1 | sort -nr | tail -1)
echo "$LARGEST is largest number"

Is This Answer Correct ?    13 Yes 15 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

How to calculate the number of passed arguments?

552


how will you find the total disk space used by a specific user?

576


c program to implement unix/linux command to block the signal ctrl-c and ctrl-\ signal during the execution ls -l|wc -l

3152


Using set -A write a script to print the output of the ls command in 5 columns with two spaces between each column. Pretend that ls does not have multicolumn output.

2029


How important is shell scripting?

543






What is the fastest scripting language?

547


I want to create a directory such that anyone in the group can create a file and access any person's file in it but none should be able to delete a file other than the one created by himself.

593


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

656


What does path stand for?

636


What is subshell?

526


What are the different types of shell scripting?

532


How do I start a shell script?

570


What is the equivalent of a file shortcut that we have a window on a linux system?

600


What is shell chemistry?

534


Is bash an operating system?

542