Write a shell script that will accept any number of command line interger parameters a d do the following....I have to use a if statment for the lowest and highest values???
Determind the lowest and highest values?
Determind the sum of all parameters entered?
1 Year Ago
Related Article:Cannot use axis command of Octave in expect !!
is a Shell Scripting discussion thread by matharoo that has 1 reply, was last updated 1 year ago and has been tagged with the keywords: axis, bash, expect, octave, script, shell.
L7Sqr was answering your question about how to store a number in a variable, which is really the first step that you need to know for the operations that you're trying to do here.
Personally, I'd use a quick and dirty temporary file for something like this, but you could also easily put your command line arguments into an array, and do a bubble sort, like in the example here: http://tldp.org/LDP/abs/html/arrays.html
One of the simplest ways to do this, however, would be to write your command line integer parameters to a temporary file and then 'sort' the file and use 'head' and 'tail' to get the lowest and highest values.
Then to sum it all up, you could loop through the file, adding each number as you go, or use 'awk' to do it in a single line.
I hope this helps. Is this for homework? It sounds like you might want to go through the bash scripting guide to get more familiar with some of the basic operations.