title: Bash search of files containing some keys combined in a Boolean expression
body: <p>Given a number of JSON files in a directory, I need to extract the names of those that contain, in a line labeled <code>"keyword:"</code>, a combination of words that match a Boolean query.</p>
  
  <p>For example:</p>
  
  <p>file <code>01</code> contains the line:</p>
  
  <pre><code>...
    "keyword": "Alabama", "Washington"
  ...
  </code></pre>
  
  <p>file <code>02</code> contains the line:</p>
  
  <pre><code>...
    "keyword": "Washington", "Pennsylvania"
  ...
  </code></pre>
  
  <p>this is how the search should work:</p>
  
  <pre><code>$ query "Washington"
  01
  02
  
  $ query "Washington &amp; !Alabama"
  02
  
  $ query "Alabama | Pennsylvania"
  01
  02
  </code></pre>
  
  <p>and so on, for any Boolean combination of individual keys, say</p>
  
  <pre><code>query "(Alabama &amp; !California) | Maine"
  </code></pre>
  
  <p><code>grep "keyword" &lt;directory&gt;</code> will extract the lines of interest, and the rest can be pipelined from there, but <code>grep</code> implementations of logical operators differ much from Boolean expressions, and <code>awk</code>, while getting closer in its syntax, doesn't seem to work for me (may be I haven't dedicated enough time to it).</p>
  
  <p>What would be a good candidate to implement this functionality, and how to translate to such an intuitive syntax?</p>