title: how to understand dollar sign ($) in sed script programming?
body: <p>everybody.
  I don't understand dollar sign ($) in sed script programming, it is stand for last line of a file or a counter of sed?
  I want to reverse order of lines (emulates "tac") of /etc/passwd. like following:</p>
  
  <pre><code>$ cat /etc/passwd | wc -l  ----&gt; 52        // line numbers
  
  $  sed '1!G;h;$!d' /etc/passwd | wc -l ----&gt; 52 // working correctly
  
  $ sed '1!G;h;$d' /etc/passwd | wc -l ----&gt; 1326    // no ! followed by $
  
  $ sed '1!G;h;$p' /etc/passwd | wc -l ----&gt; 1430    // instead !d by p
  </code></pre>
  
  <p>Last two example don't work right, who can tell me what mean does dollar sign stand for?</p>