I'm trying to write a shell program that, given an unsorted list of numbers (one per line, any sign, any size), returns the largest number given one argument or returns the smallest number given another argument. That is, if I type "myProgram 1 list", it outputs the largest number, but if I type "myProgram 0 list", it outputs the smallest number.
I think I know how to determine which number to output (switch case with the first argument?) but I have no idea how to go about finding the largest/smallest number in the list. Is there some simple way to go about finding this number? Could anyone give me a few tips? Thanks.