title: How do I decode base64 encoded lines in linux?
body: <p>I am trying to read a file &amp; extract only the base64 encoded part. I am doing so by using sed to find the lines between the pattern's 'base64' &amp; '--'. </p>
  
  <p>I am able to do so using 
  </p>
  
  <pre class="lang-html prettyprint-override"><code> sed -e '1,/base64/d' -e '/--/,$d' file.txt | sed '/^\s*$/d'
  </code></pre>
  
  
  
  <p>But when i try to decode it using base64 as shown below, 
  
  </p>
  
  <pre><code> sed -e '1,/base64/d' -e '/--/,$d' file.txt | sed '/^\s*$/d' | base64 -d
  </code></pre>
  
  
  
  <p>I get an error message as :-</p>
  
  
  
  <pre class="lang-html prettyprint-override"><code>BEGIN:VCALENDAR
  METHOD:REQUEST
  PRODID:Microsoft Exchangbase64: invalid input
  </code></pre>
  
  
  
  
  
  <p>Please let me know what am i doing wrong and is there an alternate, better way to achieve the end result. Any help is appreciated. </p>