title: Moving files to matching folders on linux command line
body: <p>I would like to copy or move files in to matching folders. 
  these are my filenames:</p>
  
  <pre><code>1-filename-aa.txt
  2-filename-aa.txt
  3-filename-aa.txt
  1-filename-bb.txt
  2-filename-bb.txt
  3-filename-bb.txt
  </code></pre>
  
  <p>these are my folder names:</p>
  
  <pre><code>aa_fa
  bb_fb
  </code></pre>
  
  <p>I tried just static examples with "cp" command but I have 40 folders like this:</p>
  
  <pre><code>cp *aa.* aa_*/
  cp *bb.* bb_*/
  </code></pre>
  
  <p>I need a loop maybe 1 line code to copy or move these files to matching folders.</p>