title: How to read mutliline input from stdin into variable and how to print one out in shell(sh,bash)?
body: <p>What I want to do is the following:</p>
  
  <ol>
  <li>read in multiple line input from <code>stdin</code> into variable <code>A</code></li>
  <li>make various operations on <code>A</code></li>
  <li>pipe <code>A</code> without losing delimiter symbols (<code>\n</code>,<code>\r</code>,<code>\t</code>,etc) to another command</li>
  </ol>
  
  <p>The current problem is that, I can't read it in with <code>read</code> command, because it stops reading at newline.</p>
  
  <p>I can read stdin with <code>cat</code>, like this:</p>
  
  <pre><code>my_var=`cat /dev/stdin`
  </code></pre>
  
  <p>, but then I don't know how to print it. So that the newline, tab, and other delimiters are still there.</p>
  
  <p>My sample script looks like this:</p>
  
  <pre><code>#!/usr/local/bin/bash
  
  A=`cat /dev/stdin`
  
  if [ ${#A} -eq 0 ]; then
          exit 0
  else
          cat ${A} | /usr/local/sbin/nextcommand
  fi
  </code></pre>