title: Bit mask in Bash
body: <p>Is something like the following code possible within a shell script?  </p>
  
  <pre><code>var1=0xA (0b1010)
  if ( (var1 &amp; 0x3) == 0x2 ){
      ...perform action...
  }
  </code></pre>
  
  <p>Just to make my intentions 100% clear my desired action would be to check bits of var1 at 0x3 (0b0011) and make sure that it equals 0x2 (0b0010)  </p>
  
  <pre><code> 0b1010
  &amp;0b0011
  _______
   0b0010 == 0x2 (0b0010)
  </code></pre>