title: Exit bash loop directly
body: <p>I have the following script</p>
  <pre><code>#!/bin/bash
      
  cat &lt;&lt; 'EOF1' &gt; textfile.txt
  text1
  text2
  text3
  text4
  text5
  text6
  text7
  text8
  text9
  text10
  text11
  EOF1
      
  function SetNumber () {
  while true; do
  cat textfile.txt
      
  echo -e '\n\nMake a selection'
  echo -e '\nSelect a option or Press Enter to Exit'
  read -p $'\nSelection : ' NUMB      
  echo
  case &quot;$NUMB&quot; in
  &quot;&quot;) if [ -z &quot;$NUMB&quot; ] ; then : ; fi ; break ;;
   *) if [[ $NUMB == text[1-11] ]] ; then CheckNumber
    elif [[ $NUMB =~ ^[0-9]+$ ]] &amp;&amp; [ ${#NUMB} -ge 1 ] &amp;&amp; [ ${#NUMB} -le 2 ] &amp;&amp; ((NUMB &gt;= 1 &amp;&amp; NUMB &lt;= 11)) ; then CheckNumber
  else echo -e ' This is not a valid choice.\n' ; fi ; SetNumber ; break ;;
  esac
  done
  }
      
  function CheckNumber () {
  if [[ $NUMB =~ ^[0-9]+$ ]] ; then NUMB=text$NUMB ; fi
  varinteth=$(awk '/^'${NUMB}'$/{print $0}' textfile.txt)
  if [ -z &quot;$varinteth&quot; ]
  then echo -e '\n You must select one of the available options.\n' ; SetNumber
  else awk '!/^'${NUMB}'$/' textfile.txt &gt; temp &amp;&amp; mv temp textfile.txt ; fi
  }
      
  SetNumber
  </code></pre>
  <p>If I press 1 it follows the steps and remove text1 from textfile.txt</p>
  <p>if I press by mistake 1 again it show me the message to select one of the availables options and returns to the SetNumber function as it should be but if then I press enter to exit it show me the
  Make a selection again and I have to press enter again to exit.</p>
  <p>as I understand this happens so many times as many I press by mistake an option I have made again</p>
  <p>What I have to do to exit directly when I press enter after a mistake ?</p>
  <p>p.s. I don't know if my title is the right one but I don't know exactly what title should I put.
  If you have a better idea, tell her so I can change it</p>