title: "git rm -r" with globbing
body: <p>I'm trying to use <code>git rm</code> as part of the filter-branch. I want to delete directories <code>*/*/dir1</code> but nothing is happening.
  The command I'm using is:</p>
  
  <pre><code>git filter-branch --tag-name-filter cat --index-filter "git rm -r --cached --ignore-unmatch */*/dir1" --prune-empty -f -- --all
  </code></pre>
  
  <p>Command</p>
  
  <pre><code>find . -wholename "*/*/dir1"
  </code></pre>
  
  <p>shows a lot of matches.</p>
  
  <p>How I could remove those directories?</p>
  
  <p>Update: I'm trying to remove these folders from the history.</p>
  
  <h1>Solution:</h1>
  
  <p>With combination of the answers from @j6t and @Sam Gleske here is my solution:</p>
  
  <pre><code>git filter-branch --tag-name-filter cat \
     --index-filter 'git ls-files | grep -E "^([^/]+/){2,3}dir1" |
                     xargs -I {} --no-run-if-empty git rm -r --cached "{}"' \
     --prune-empty -f -- --all
  </code></pre>