title: sed awk get substring instead - regex
body: <p>Hi how to use sed or awk to extract substring that matches a regular expression. </p>
  
  <p>I have seen several modify or change substring but I just want to get the matching part. </p>
  
  <p>my data looks like below:</p>
  
  <pre><code>&lt;loc&gt;http://www.A.com/sitemap1.gz&lt;/loc&gt;
  &lt;loc&gt;http://www.A.com/sitemap2.gz&lt;/loc&gt;
  &lt;loc&gt;http://www.A.com/sitemap3.gz&lt;/loc&gt;
  &lt;loc&gt;http://www.A.com/sitemap4.gz&lt;/loc&gt;
  &lt;loc&gt;http://www.A.com/sitemap5.gz&lt;/loc&gt;
  &lt;loc&gt;http://www.A.com/sitemap6.gz&lt;/loc&gt;
  &lt;loc&gt;http://www.A.com/sitemap7.gz&lt;/loc&gt;
  &lt;loc&gt;http://www.A.com/sitemap8.gz&lt;/loc&gt;
  </code></pre>
  
  <p>Output should look like </p>
  
  <pre><code>http://www.A.com/sitemap1.gz
  http://www.A.com/sitemap2.gz
  http://www.A.com/sitemap3.gz
  ....
  </code></pre>
  
  <p>I tried </p>
  
  <pre><code>cat data | sed 's/'http.*gz'//' 
  </code></pre>
  
  <p>but this command actually removes exactly the part that I want to keep. 
  Thanks</p>