title: decode Base64 from shell
body: <p>Help if possible,please.
  I want to reconstruct the file try.txt</p>
  
  <p>try.txt contains:</p>
  
  <pre><code>uid: random1
  sn: 8
  
  uid: random2
  sn:: SGVsbG8sIFdvcmxkIQo=
  </code></pre>
  
  <p>to this:</p>
  
  <pre><code>random1 8
  random2 Hello, World!
  </code></pre>
  
  <p>the problem is in Base64. Whats the best and possible way to decode it?</p>
  
  <p>1) Search though try.txt line by line and decode on matching string
  Is this possible to do with awk or is this wishful thinking?
  This doesn't work -> <code>cat try.txt |  awk '{if ($1 == "sn::") base64 -d $2'</code></p>
  
  <p>2) search through sn.txt line by line and decode on matching string</p>
  
  <pre><code>path=/dev/shm
  uidf=$path/uid.txt
  snf=$path/sn.txt
  ff=$path/ff.txt
  </code></pre>
  
  <p>some code to search through $snf for different Base64 encoded text
  could you help with this?
  2a)<br>
      cat try.txt |  grep -v dn: | awk '/uid/ {print $2}' > $uidf
      cat try.txt |  grep -v dn: | awk '/sn/ {print $2}' > $snf</p>
  
  <p>here some code to search for base64 encoded string and decode it</p>
  
  <pre><code>paste $uidf $snf | awk '{print $1,$2}' &gt; $ff
  </code></pre>
  
  <p>2b)
      cat try.txt |  grep -v dn: | awk '{print}'</p>
  
  <pre><code>case "$string" in
      "sn::" ) base64 -d $string;;
  esac
  </code></pre>