title: How do I loop over multiple wildcards simultaneously in bash?
body: <p>In bash, I've written a function that loops over files in a directory with multiple extensions using wildcards, and copies only these specific files if they exist. A snippet of the code looks like this:</p>
  
  <pre><code>set -e
  
  pushd ../../../../$3/code/project/common/ &gt; /dev/null
  mkdir -p ../$2
  shopt -s nullglob
  
  for file in *.gyp; do   cp $file ../$2/; done
  for file in *.gypi; do  cp $file ../$2/; done
  for file in *.sh; do    cp $file ../$2/; done
  for file in *.patch; do cp $file ../$2/; done
  
  popd &gt; /dev/null
  </code></pre>
  
  <p>I'd prefer instead to write one <code>for file in x</code> statement, so that I don't have to copy and paste this line for each extension I want to copy.</p>
  
  <p>How can I rewrite the four <code>for</code> statements as one <code>for</code> statement? I would like to keep the <code>*.ext</code> wildcard format somewhere in there if possible.</p>