title: Using sed to mass rename files
body: <p><strong>Objective</strong></p>
  
  <p>Change these filenames:</p>
  
  <ul>
  <li>F00001-0708-RG-biasliuyda</li>
  <li>F00001-0708-CS-akgdlaul</li>
  <li>F00001-0708-VF-hioulgigl</li>
  </ul>
  
  <p>to these filenames:</p>
  
  <ul>
  <li>F0001-0708-RG-biasliuyda</li>
  <li>F0001-0708-CS-akgdlaul</li>
  <li>F0001-0708-VF-hioulgigl</li>
  </ul>
  
  <p><strong>Shell Code</strong></p>
  
  <p>To test:</p>
  
  <pre><code>ls F00001-0708-*|sed 's/\(.\).\(.*\)/mv &amp; \1\2/'
  </code></pre>
  
  <p>To perform:</p>
  
  <pre><code>ls F00001-0708-*|sed 's/\(.\).\(.*\)/mv &amp; \1\2/' | sh
  </code></pre>
  
  <p><strong>My Question</strong></p>
  
  <p>I don't understand the sed code.  I understand what the substitution
  command</p>
  
  <pre><code>$ sed 's/something/mv'
  </code></pre>
  
  <p>means.  And I understand regular expressions somewhat.  But I don't
  understand what's happening here:</p>
  
  <pre><code>\(.\).\(.*\)
  </code></pre>
  
  <p>or here:</p>
  
  <pre><code>&amp; \1\2/
  </code></pre>
  
  <p>The former, to me, just looks like it means: "a single character,
  followed by a single character, followed by any length sequence of a
  single character"--but surely there's more to it than that.  As far as
  the latter part:</p>
  
  <pre><code>&amp; \1\2/
  </code></pre>
  
  <p>I have no idea.</p>