title: How to read from a file or standard input in Bash
body: <p>The following Perl script (<code>my.pl</code>) can read from either the file in the command line arguments or from <a href="https://en.wikipedia.org/wiki/Standard_streams#Standard_input_(stdin)" rel="noreferrer">standard input</a> (STDIN):</p>
  <pre><code>while (&lt;&gt;) {
     print($_);
  }
  </code></pre>
  <p><code>perl my.pl</code> will read from standard input, while <code>perl my.pl a.txt</code> will read from <code>a.txt</code>. This is very handy.</p>
  <p>Is there an equivalent in Bash?</p>