title: Save output of bash command for use with pipe command (|)
body: <p>Say I have the following problem</p>
  
  <ul>
  <li>Count the files in the folder which have an "a" in the filename</li>
  <li>Repeat for "e", "i" and all the other vowels</li>
  </ul>
  
  <p>One solution is:</p>
  
  <pre><code>FilesWithA=$(ls | grep a | wc -l)
  FilesWithE=$(ls | grep e | wc -l)
  FilesWithI=$(ls | grep i | wc -l)
  FilesWithO=$(ls | grep o | wc -l)
  FilesWithU=$(ls | grep u | wc -l)
  </code></pre>
  
  <p>This works fine, but the folder contains many thousands of files. I'm looking to speed this up by capturing the output of <code>ls</code> in a variable, then sending the output to <code>grep</code> and <code>wc</code>, but the syntax is defeating me.</p>
  
  <pre><code>lsCaptured=$(ls)
  FilesWithA=$($lsCaptured | grep a | wc -l) #not working!
  </code></pre>