title: How to feed a list of files into a bash script
body: <p>I'm having problems feeding a large list of filenames into a command in (git for windows git, I think it's cygwin)bash shell.</p>
  
  <p>This is the basic command that works fine with a small set of arguments: <code>git filter-branch -f --tree-filter 'rm -rf file1 directory2 file3 file4'</code>  However, I have about 1500 filenames.</p>
  
  <p>I've tried: <code>git filter-branch -f --tree-filter 'rm -rf file1 directory2... all 1500 names here'</code> but I get an error: </p>
  
  <blockquote>
    <p>/mingw64/bin/git: Argument list too long</p>
  </blockquote>
  
  <p>I've tried to use a for loop: <code>git filter-branch -f --tree-filter 'for f in $(cat files.txt) ; do  rm -fr "$f" ; done'</code> and this runs through the loop with an error:  </p>
  
  <blockquote>
    <p>cat: files.txt: No such file or directory</p>
  </blockquote>
  
  <p>FYI - the files.txt contents look like this:</p>
  
  <pre><code>./file1 
  ./directory2 
  ./file3 
  ./file4
  </code></pre>
  
  <p>Then I tried: <code>git filter-branch -f --tree-filter &lt; cat files.txt</code> and <code>cat files.txt | git filter-branch -f --tree-filter</code> but I get errors about the syntax not being correct - it shows the 'help' dialogue. eg:</p>
  
  <blockquote>
    <p>usage: git filter-branch [--setup ] [--subdirectory-filter
    ] [--env-filter ]
            [--tree-filter ] [--index-filter ]
            [--parent-filter ] [--msg-filter ]
            [--commit-filter ] [--tag-name-filter ]
            [--original ]
            [-d ] [-f | --force] [--state-branch ]
            [--] [...]</p>
  </blockquote>
  
  <p>Then I thought maybe I could just add the arguments into the file like this: <code>git filter-branch -f</code></p>
  
  <p>File: </p>
  
  <pre><code>--tree-filter './file1 ./directory2 ./file3 ./file4'
  </code></pre>
  
  <p>But I get the 'help' dialogue again.</p>
  
  <p>I'm sure there is a way to do this, but my unix-fu is too weak.  Please help! </p>
  
  <hr>
  
  <p>In response to @dash-o:</p>
  
  <p>I tried this, but am getting an error: </p>
  
  <blockquote>
    <p>C:/Program Files/Git/mingw64/libexec/git-core\git-filter-branch: eval:
    line 414: unexpected EOF while looking for matching `'' C:/Program
    Files/Git/mingw64/libexec/git-core\git-filter-branch: eval: line 415:
    syntax error: unexpected end of file</p>
  </blockquote>
  
  <p>The files.txt lists the files one per line.  However, the rm -rf requires them to be on a single line and space-delimited.  </p>
  
  <p>I tried to put the files names on a single line, but I get a different error:  </p>
  
  <blockquote>
    <p>C:/Program Files/Git/mingw64/libexec/git-core\git-filter-branch: line
    414: rm -rf .vs ./file1 ./directory2: command not found tree filter
    failed: 'rm -rf ./file1 ./directory2'</p>
  </blockquote>
  
  <p>Maybe the single quotes are being escaped and are not wrapped around the rm command?</p>