title: Making a bash script to accept input from file OR piping output
body: <p>I have the following bash script which takes the tabular data as input, 
  get the first line and spit them vertically:</p>
  
  <pre><code>#!/bin/bash  
  # my_script.sh
  export LC_ALL=C
  file=$1
  head -n1  $file |
  tr "\t" "\n" |
  awk '{print $1 " " NR-1}'
  </code></pre>
  
  <p>The problem is that I can only execute it this way:</p>
  
  <pre><code>$ myscript.sh some_tab_file.txt 
  </code></pre>
  
  <p>What I want to do is on top of the above capability also allows you to do this:</p>
  
  <pre><code>$ cat some_tab_file.txt myscript.sh | myscript.sh 
  </code></pre>
  
  <p>Namely take it from pipe output. How can I achieve that?</p>