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

Answer Posted / aseem

Hi Imran,

Could you please run your script with below parameter
4 45 1. It will give the output as "1 is the largest number"
reason is you have used only sort command not sort -nr so it will not sort in reverse order, so in your case head -1 will rather than tail -1.

Hi A,

Regarding your answer you have to run by below way.

say you are keeping your script in file test.sh
then

sh test.sh 43 1 34

Actually it takes the positional parameter so after script whatever input you provide it takes as parameter.

Feel free to send me email aseem02@gmail.com if you have any doubt regarding shell scripting, will glad to help you guys.

Is This Answer Correct ?    3 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What does echo mean in scripting?

776


Differentiate between ‘ and ” quotes.

791


Rewrite the command to print the sentence and convert the variable to plural: echo “i like $variable”.

806


What is scripting autism?

907


What is gui scripting?

783


What does path stand for?

813


How will you find the 99th line of a file using only tail and head command?

2253


What is a shell made of?

736


How do I run a script from command prompt?

745


What does .sh file contain?

722


What is the lifespan of a variable inside a shell script?

1344


What is the way to do multilevel if-else's in shell scripting?

945


What is awk in shell scripting?

779


What does it mean by #!/Bin/sh or #!/Bin/bash at the beginning of every script?

783


What is a scripting language simple definition?

784