title: Linux shell: Base64 Decode with removing line breaks
body: <p>I have a file where each line is a base64-encoded XML document. The decoded XML documents may contain new line characters. I would like to grep out each XML document containing a given word.</p>
  
  <p>The problem is that, when I decode the lines of the file, I have multiple lines for each base64-encoded line and I cannot grep it any more. I need something like <code>base64 decode + remove line breaks</code> in one step.</p>
  
  <p>How can I achieve that in the Linux shell? I have Python, Perl and awk available.</p>
  
  <pre class="lang-none prettyprint-override"><code>&gt;cat fileContainingBase64EncodedXMLsInEachLine.txt | what should I write here?
  </code></pre>
  
  <h3>Input:</h3>
  
  <pre class="lang-none prettyprint-override"><code>PGZvbz4NCjxiYXIvPg0KPC9mb28+
  PGZvbz4NCjxodWh1Lz4NCjwvZm9vPg==
  PGZvbz4NCjxiYXJvbWV0ZXIvPg0KPC9mb28+
  </code></pre>
  
  <h3>Expected Output</h3>
  
  <p>Let's say I want the XML documents containing 'bar'</p>
  
  <pre class="lang-none prettyprint-override"><code>&lt;foo&gt;
  &lt;bar/&gt;
  &lt;/foo&gt;
  &lt;foo&gt;
  &lt;barometer/&gt;
  &lt;/foo&gt;
  </code></pre>
  
  <h3>An example for my problem</h3>
  
  <pre class="lang-none prettyprint-override"><code>&gt;cat fileContainingBase64EncodedXMLsInEachLine.txt | base64 --decode | grep bar
  </code></pre>
  
  <p>Delivers:</p>
  
  <pre class="lang-none prettyprint-override"><code>&lt;bar/&gt;
  &lt;barometer/&gt;
  </code></pre>
  
  <p>So I do not have the full xml documents containing <code>bar</code> and <code>barometer</code>.</p>