title: Shell Script Issue with Multiple Filetypes
body: <p>Some of my files are separated into different directories such as <em>/apps</em>, <em>/games</em>, <em>/docs</em> etc....
  Within each directory, is a subdirectory called <em>_CHECKSUM</em>.  Inside this directory, is a file called <em>openssl.sh</em>.</p>
  
  <p>For example:</p>
  
  <pre><code>openssl sha1 /path/to/apps/*.iso | sed 's/\/.*.\///' &gt; /path/to/apps/_CHECKSUM/sum.sha1
  </code></pre>
  
  <p>This outputs to a file called <em>sum.sha1</em> within the <em>_CHECKSUM</em> directory, of which the contents could look like this:</p>
  
  <pre><code>SHA1(anApp.iso)= b398c8b175411e6174942d7b4acbc5c90473a852
  SHA1(anotherApp.iso)= cc150483feed3d4b607749f31eddccefd0ba5478
  SHA1(yetAnotherApp.iso)= d9682a2eca25b70dddf7a906374c27ee35614c7d
  </code></pre>
  
  <p>However, some directories contain multiple filetypes, so the script would have to look like this:</p>
  
  <pre><code>openssl sha1 /path/to/games/*.{7z,iso} | sed 's/\/.*.\///' &gt; /path/to/games/_CHECKSUM/sum.sha1
  </code></pre>
  
  <p>producing something like this:</p>
  
  <pre><code>SHA1(myFaveGame.7z)= b398c8b175411e6174942d7b4acbc5c90473a852
  SHA1(anotherGoodGame.iso)= cc150483feed3d4b607749f31eddccefd0ba5478
  </code></pre>
  
  <p>I don't want to always run these scripts manually, so I created the following script, <em>/path/to/scripts/openssl_recursive.sh</em>:</p>
  
  <pre><code>#!/bin/bash
  # finds every openssl.sh recursively and executes it.
  IFS=$'\n'
  for file in $(find /path/to -name "openssl.sh" | sort -n)
  do
    echo "executing $file ..."
    sh $file
    echo "done.";
  done
  </code></pre>
  
  <p>This seems to work fine for all directories where just one file type exists.  However, for the <em>openssl.sh</em> scripts that contain multiple extensions, an empty <em>sum.sha1</em> file is created.</p>
  
  <p>Why is it that if I run the <em>openssl.sh</em> directly, it will create the correct result in <em>sum.sha1</em> for directories with multiple filetypes, yet if I run the <em>openssl_recursive.sh</em>, this results in an empty <em>sum.sha1</em>?</p>