title: Using case for a range of numbers in Bash
body: <p>I am trying to do the following using <code>case</code> in Bash (in Linux).</p>
  
  <p>If X is between 460 and 660, output X information.</p>
  
  <p>If X is between 661 and 800, do something else.</p>
  
  <p>Etc.</p>
  
  <p>Right now this is what I have:</p>
  
  <pre><code>case $MovieRes in
      [461-660]*) echo "$MovieName,480p" &gt;&gt; moviefinal ;;
      [661-890]*) echo "$MovieName,720p" &gt;&gt; moviefinal ;;
      [891-1200]*) echo "$MovieName,1080p" &gt;&gt; moviefinal ;;
      *) echo "$MovieName,DVD" &gt;&gt; moviefinal ;;
  esac
  </code></pre>
  
  <p>But somehow many of the ones that are 480p, 720p or 1080p are ending with DVD instead. The variable <code>$MovieRes</code> is a simple list that shows, for each line, a number between 1 and 1200. Depending on the value, <code>case</code> decides which "case" to apply.</p>
  
  <p>I would like to know how to actually use <code>case</code> to accomplish this since it is a bit confusing when dealing with ranges like this.</p>