title: Struggling with while loop with two conditions and a for loop
body: <p>I'm trying to learn how to use arrays in bash. I'm writing a script that asks the user for three numbers and figures out what the biggest number is. I want the script to force the user to enter only numeric values. Furthermore, I want the three numbers should be different. I'm using an array to store user input. This is what I have so far:</p>
  
  <pre><code>## declare variables
  order=("first" "second" "third")
  answers=()
  RED='\033[0;31m'
  NC='\033[0m' # No Color
  
  numbersonly() {
          if [[ ! $1 =~ ^[0-9]+$ ]]; then
          echo "${RED}$1 is not a valid number.${NC}"
          else
              answers+=("$input")
              break
          fi
  }
  
  inarray(){
      for e in ${answers[@]}; do
      if [[ $1 == $e ]]; then
      echo "${RED}Warning.${NC}"
      fi
      done
  }
  
  readnumber(){
  for i in {1..3}; do
  j=$(awk "BEGIN { print $i-1 }")
      while read -p "Enter the ${order[$j]} number: " input ; do      
      inarray $input
      numbersonly $input
      done
  done
  }
  
  displayanswers(){
  echo "Your numbers are: ${answers[@]}"
  }
  
  biggestnumber(){
  
  if (( ${answers[0]} &gt;= ${answers[1]} )); then
          biggest=${answers[0]}
          else
          biggest=${answers[1]}
          fi
  if (( $biggest &lt;= ${answers[2]} )); then
          biggest=${answers[2]}
          fi  
  echo "The biggest number is: $biggest"
  }
  
  main(){
  readnumber
  displayanswers
  biggestnumber
  }
  
  main
  </code></pre>
  
  <p>Right now, I can get the script to display a warning when the user enters a number that was previously entered, but I can't seem to find the proper syntax to stay in the while loop if the user input has already been entered. Thoughts?</p>