title: command line to read from stdin or file
body: <p>I have a command which runs like this:</p>
  
  <pre><code>$ cmd &lt;file_name&gt; [option]
  </code></pre>
  
  <p>The <code>[option]</code> is optional and the command can read from <code>stdin</code>. So following commands are OK:</p>
  
  <pre><code>$ cmd file
  $ cmd file option
  $ cat file | cmd
  </code></pre>
  
  <p>However, reading from <code>stdin</code> with <code>[option]</code> gives error:</p>
  
  <pre><code>$ cat file | cmd option
  Cannot open file: option
  </code></pre>
  
  <p>So how to construct the command, or I have to change the program to read from <code>stdin</code> correctly?</p>
  
  <p>Thanks.</p>