title: How do I find the middle of three numbers in shell script
body: <pre><code>#!/bin/bash
  
  echo "Enter three numbers and this program will give you the middle number : " ; read num1 ; read num2 ; read num3
  
  if [ "$num1" -gt "$num2" ] &amp;&amp; [ "$num1" -lt "$num3" ] || [ "$num1" -lt "$num2" ] &amp;&amp; [ "$num1" -gt "$num3" ]; then
  {
  echo "The middle number is $num1"
  }
  
  elif [ "$num2" -gt "$num1" ] &amp;&amp; [ "$num2" -lt "$num3" ] || [ "$num2" -lt "$num1" ] &amp;&amp; [ "$num2" -gt "$num3" ]; then
  {
  echo "The middle number is $num2"
  }
  
  elif [ "$num3" -gt "$num1" ] &amp;&amp; [ "$num3" -lt "$num2" ] || [ "$num3 -lt "$num1" ] &amp;&amp; [ "$num3" -gt "$num2" ]; then
  { echo "The middle number is $num3" }
  
  fi
  </code></pre>
  
  <p>The problem I have is with the or condition. I input the numbers 1, 2, and 3, but I get the middle number as 1 all the time.</p>