Does a way exist to find the min and max in...
Solved
Swiss Knight
Posted messages
2257
Status
Membre
-
Swiss Knight Posted messages 2257 Status Membre -
Swiss Knight Posted messages 2257 Status Membre -
Hello!
Is there a simple way in bash to find the minimum and maximum of numbers contained in a string?
Example:
$ A=78,99,12
A trick that returns 12 as minimum and 99 as maximum?
Better: a trick that returns the average of the min found and the max found, i.e. here (99+12)/2
rounded to the nearest integer (well, in this case it will be the next higher integer, but if we divided by 3 it could be different)
I couldn't find a function like that:
min(A)=12
max(A)=99
not even in bc.
Thank you very much!
--
"If you can't explain a concept to a six-year-old, you don't understand it completely." -A. Einstein-
Is there a simple way in bash to find the minimum and maximum of numbers contained in a string?
Example:
$ A=78,99,12
A trick that returns 12 as minimum and 99 as maximum?
Better: a trick that returns the average of the min found and the max found, i.e. here (99+12)/2
rounded to the nearest integer (well, in this case it will be the next higher integer, but if we divided by 3 it could be different)
I couldn't find a function like that:
min(A)=12
max(A)=99
not even in bc.
Thank you very much!
--
"If you can't explain a concept to a six-year-old, you don't understand it completely." -A. Einstein-