title: In Linux shell script how do i print the largest and smallest values of a array?
body: <p>I dont really understand much about arrays but  i need to know how to find and print the largest and smallest values of an array. The array is predefined by a read command, the user will be prompted to enter n amount of integers. </p>
  
  <p>How would i assign the read input to an array and find and display the largest and smallest values of the array?</p>
  
  <p>Is there a way to test the array elements to see if they are all integers?</p>
  
  <pre><code>#!/bin/bash
  
  read -a integers
  
  biggest=${integers[0]}
  smallest=${integers[0]}
  
  for i in ${integers[@]}
  do
       if [[ $i -gt $biggest ]]
       then
          biggest="$i"
       fi
  
       if [[ $i -lt $smallest ]]
       then
          smallest="$i"
       fi
  done
  
  echo "The largest number is $biggest"
  echo "The smallest number is $smallest"
  </code></pre>