How can I find the maximum element and its index from an array in shell script. I have an array
a = [-2.2116565098 -2.1238242060 -2.1747941240 -2.3201010162 -2.3677779871 -1.8126464132 -2.1247209755 -2.1190930712 -2.3242384636 -2.1081702064];
Now, I want to find the maximum as well as its index in bash script. Is there a shortcut like in Matlab we have
[C, I] = max(a);
Also, also how can we have multi-dimensional array and get the index and value of minimum and maximum element.
1 Answer