title: Bash: list different prefixes of files
body: <p>Suppose we have series of files, listed as:</p>
  
  <pre><code>T001_000.txt
  T001_001.txt
  T001_002.txt
  T005_000.txt
  T005_001.txt
  T012_000.txt
  ...
  T100_000.txt
  </code></pre>
  
  <p>We want to merge files with same T??? prefix. For example, every file with prefix T001 we want to do:</p>
  
  <pre><code>merge T001_*.txt &gt; newT001.txt #i just made up this function
  </code></pre>
  
  <p>How to get from bash list of different prefixes?</p>