title: BASH Script to iterate through a list of IDs in an XML file and print/output the name to shell or output file?
body: <p>I'm looking to iterate through a list of ID numbers which matches ID numbers in an XML file and print the line below using BASH (and AWK) to the shell or redirect it to a third, output file (output.txt)</p>
  
  <p>Here is the breakdown:</p>
  
  <p>ID_list.txt (shortened for this example - it has 100 IDs)</p>
  
  <pre><code>4414
  4561
  2132
  999
  1231
  34
  489
  3213
  7941
  </code></pre>
  
  <p>XML_example.txt (thousands of entries)</p>
  
  <pre><code>&lt;book&gt;
    &lt;ID&gt;4414&lt;/ID&gt;
    &lt;name&gt;Name of first book&lt;/name&gt;
  &lt;/book&gt;
  &lt;book&gt;
    &lt;ID&gt;4561&lt;/ID&gt;
    &lt;name&gt;Name of second book&lt;/name&gt;
  &lt;/book&gt;
  </code></pre>
  
  <p>I'd like the output of the script to be the names of the 100 IDs from the first file:</p>
  
  <pre><code>Name of first book
  Name of second book
  etc
  </code></pre>
  
  <p>I believe it's possible to do this using BASH and AWK with a for loop (for each in file 1, find the corresponding name in file2). I think you can recurisvely GREP for the ID number and then print the line below it using AWK. Even if the output looked like this, I can remove the XML tags after:</p>
  
  <pre><code>&lt;name&gt;Name of first book&lt;/name&gt;
  &lt;name&gt;Name of second book&lt;/name&gt;
  </code></pre>
  
  <p>It's on a Linux server but I can port it over to PowerShell on Windows. I think BASH/GREP and AWK are the way to go.</p>
  
  <p>Can someone help me script this?</p>