title: MacOS - One line command is working in terminal but not in .sh script?
body: <p>MacOS High Sierra</p>
  
  <p>I have a command that I currently use in terminal:</p>
  
  <pre><code>find /private/my/tmp -mindepth 1 -maxdepth 1 -type d -not -name -specialfolder -exec rm -r {} \;
  </code></pre>
  
  <p>which searches the folder private/my/tmp and removes all folders except one that is named "specialfolder".</p>
  
  <p>This is working perfectly from the terminal, but I cannot get it working as .sh shell script. I have used <code>chmod +x /scripts/myscript.sh</code> to make it executable but this has not made any difference.</p>
  
  <p>The shell script is:</p>
  
  <pre><code>#!/bin/sh
  find /private/my/tmp -mindepth 1 -maxdepth 1 -type d -not -name -specialfolder -exec rm -r {} \;
  </code></pre>
  
  <p>Running it from the terminal as "sh myscript.sh" does not produce any result, no errors, nothing.</p>
  
  <p>What do I need to fix to get this to work as a .sh script?</p>
  
  <p><em>PS - I had considered it may be a permissions issue, but I have set permissions with chmod -R 777 on the /private/my/tmp folder and still no difference.</em></p>