title: Linux cp with a regexp
body: <p>I would like to copy some files in a directory, renaming the files but conserving extension. Is this possible with a simple <code>cp</code>, using regex ?</p>
  
  <p>For example : </p>
  
  <pre><code>cp ^myfile\.(.*) mydir/newname.$1
  </code></pre>
  
  <p>So I could copy the file conserving the extension but renaming it. Is there a way to get matched elements in the <code>cp</code> regex to use it in the command ?
  If not, I'll do a perl script I think, or if you have another way...</p>
  
  <p>Thanks</p>