title: Reporting with cut and grep
body: <p>I'm trying to create a script that gets an extension and reports in two columns, the user and the amount of files that user owns with that extension.
  The results must be printed in report.txt</p>
  
  <p>Here is my code.</p>
  
  <pre><code>#!/bin/bash
  
  #Uncoment to create /tmp/test/ with 50 txt files
  #mkdir /tmp/test/
  #touch /tmp/test/arch{01..50}.txt
  
  clear
  
  usage(){
      echo "The script needs an extension to search"
      echo "$0 &lt;extension&gt;"
  }
  
  if [ $# -eq 0 ]; then
      usage
      exit 1
  fi
  
  folder="/tmp/test/"
  touch report.txt
  count=0
  pushd $folder
  
  for file in $(ls -l); do
      grep "*.$1" | cut -d " " -f3 &gt;&gt; report.txt
  done
  
  popd
  </code></pre>
  
  <p>The program just runs endlessly. And I'm not even counting the files for each user.
  How can I solve this using only grep and cut?</p>