title: Grep $value `grep $value2 `<command>`` - Nested grep?
body: <p>I'm a complete noob at awk/sed so forgive me if I'm missing something obvious here.</p>
  
  <p>Basically I'm trying to do a nested grep, i.e. something akin to:</p>
  
  <pre><code>grep $value `exim -Mvh $(`exim -bpru | grep $eximID | more`)`
  </code></pre>
  
  <p>Breakdown:</p>
  
  <pre><code>grep $value IN COMMAND 
  --&gt; exim -Mvh (print exim mail headers) FROM RESULTS OF 
      ---&gt; exim -bpru | grep $eximID | more
  </code></pre>
  
  <ul>
  <li><code>$value</code> is the string I'm looking for</li>
  <li><code>$eximID</code> is the string I'm looking for within exim -bpru (list all exim thingies)</li>
  </ul>
  
  <p>No idea if what I'm trying to accomplish would be easier with awk/sed hence the question really.</p>
  
  <p>I <em>tried</em> to make that as legible as possible but nested nesting is hard yo</p>
  
  <p><em><strong>Edit</em></strong>
  Tada! My script is now workings thanks to you guys! Here it is, unfinished, but working:</p>
  
  <pre><code>#!/usr/bin/bash
  
      echo "Enter the email address you want to search for + compare sender info via exim IDs."
      read searchTarget
      echo "Enter the target domain the email is coming from."
      read searchDomain
  
      #domanList is array for list of exim IDs needed
      domainList=($(exim -bpru | grep "$searchDomain" | awk '{ print $3 }'))
  
  
      for i in "${domainList[@]}"
              do
                      echo "$(exim -Mvh  $i | grep $searchTarget)"
                      #echo "$(grep $searchTarget $(exim -Mvh $i))"
              done
  </code></pre>