title: sed: print only matching group
body: <p>I want to grab the last two numbers (one int, one float; followed by optional whitespace) and print only them.</p>
  
  <p>Example:</p>
  
  <pre><code>foo bar &lt;foo&gt; bla 1 2 3.4
  </code></pre>
  
  <p>Should print:</p>
  
  <pre><code>2 3.4
  </code></pre>
  
  <p>So far, I have the following:</p>
  
  <pre><code>sed -n  's/\([0-9][0-9]*[\ \t][0-9.]*[\ \t]*$\)/replacement/p' 
  </code></pre>
  
  <p>will give me</p>
  
  <pre><code>foo bar &lt;foo&gt; bla 1 replacement
  </code></pre>
  
  <p>However, if I try to replace it with group 1, the whole line is printed.</p>
  
  <pre><code>sed -n  's/\([0-9][0-9]*[\ \t][0-9.]*[\ \t]*$\)/\1/p' 
  </code></pre>
  
  <p>How can I print only the section of the line that matches the regex in the group?</p>