title: BASH Script using awk to extract a key
body: <p>I'm creating dkim private &amp; public keys
  openssl genrsa -out dkim1024.key 1024
  openssl rsa -in dkim1024.key -out dkim1024.pub -pubout -outform PEM</p>
  
  <p>I have a bash script using awk to extract a key file 
  KEY=<code>/usr/bin/awk 'NR&gt;1{a[++k]=$0}END{for(i=1;i&lt;k;i++)print a[i]}' file.key</code></p>
  
  <p>file.key contents </p>
  
  <pre><code>-----BEGIN PUBLIC KEY-----
  MIGfMA0GCSqasdfadaBAQUAA4GNADCBiQKBsdfadsfsDgrKE5D2atbGtaqVmAZwzy1YNY
  8pUYgF6qQ4zecRrpk3Uam52asdfafasdasdfasgwYAA0x3roKIYAeHFFrFm9aCS
  WKpM+na/03akmpewn4cjT4sm9qTHP0q/VM/YtHy3rGkPj+xzOKgO9rzyZo3E1a1O
  HYu6TIqqzlqtadfafafafdas
  -----END PUBLIC KEY-----
  </code></pre>
  
  <p>I need to remove the lines.
  -----BEGIN PUBLIC KEY-----
  -----END PUBLIC KEY-----
  I've done this in my awk cmd but when I echo $KEY There are spaces. I'm guessing that these are return chars but I'm not sure how to get rid of them but preserve the key. </p>
  
  <pre><code>sh-3.2# echo $KEY
  MIGfMA0GCSqasdfadaBAQUAA4GNADCBiQKBsdfadsfsDgrKE5D2atbGtaqVmAZwzy1YNY 8pUYgF6qQ4zecRrpk3Uam52asdfafasdasdfasgwYAA0x3roKIYAeHFFrFm9aCS WKpM+na/03akmpewn4cjT4sm9qTHP0q/VM/YtHy3rGkPj+xzOKgO9rzyZo3E1a1O HYu6TIqqzlqtadfafafafdas
  </code></pre>
  
  <p>Thanks</p>