title: Check if a variable exists in a list in Bash
body: <p>I am trying to write a script in bash that check the validity of a user input.<br />
  I want to match the input (say variable <code>x</code>) to a list of valid values.</p>
  <p>what I have come up with at the moment is:</p>
  <pre><code>for item in $list
  do
      if [ &quot;$x&quot; == &quot;$item&quot; ]; then
          echo &quot;In the list&quot;
          exit
      fi
  done
  </code></pre>
  <p>My question is if there is a simpler way to do this,<br />
  something like a <code>list.contains(x)</code> for most programming languages.</p>
  <p>Say list is:</p>
  <pre><code>list=&quot;11 22 33&quot;
  </code></pre>
  <p>my code will echo the message only for those values since <code>list</code> is treated as an array and not a string,
  all the string manipulations will validate <code>1</code> while I would want it to fail.</p>