title: How to convert multiline file into a string in bash with newline character?
body: <p>How can I convert a file with multiple lines to a string with <code>\n</code> characters in bash? </p>
  
  <p>For example - I have a certificate that I need to configure in my configuration <code>JSON</code> file
  so instead of having </p>
  
  
  
  <pre class="lang-none prettyprint-override"><code>-----BEGIN CERTIFICATE-----
  MIIDBjCCMIIDB
  MIIDBjCCMIIDB
      .... 
  MIIDBjCCMIIDB==
  -----END CERTIFICATE-----
  </code></pre>
  
  <p>I will have </p>
  
  <pre class="lang-none prettyprint-override"><code>-----BEGIN CERTIFICATE-----\nMIIDBjCCMIIDB\nMIIDBjCCMIIDB\n....\nMIIDBjCCMIIDB==\n-----END CERTIFICATE-----
  </code></pre>