title: Bash script to extract filenames from git whatchanged
body: <p>I'm trying to get a list of all the js files that changed to know what to reminify.</p>
  
  <p>I previously asked <a href="https://stackoverflow.com/questions/9361496/save-a-modified-log-right-before-a-commit/9361595#comment11832771_9361595"><strong>this</strong></a> question</p>
  
  <p>So far this is the best I came up with but it feels really unsafe.</p>
  
  <pre><code>GITCHANGES=$(git whatchanged -n 1 --pretty=format:)
  I=0;
  for f in $GITCHANGES;
  do
      I=$(($I + 1));
      if [[ $(($I % 6 )) == 0 ]]; then
          echo "$f"
      fi
  done
  </code></pre>
  
  <p>But this gives me all the files that changed (<code>php</code> <code>css</code> <code>js</code>) and not just the <code>js</code> files</p>
  
  <p>How would I get just the js files? Also is there a better way to accomplish this?</p>