title: for loop works in console but not ran as a shell script
body: <pre><code>for files in $(find . -maxdepth 1 -type f); do
    echo $(basename $files)
  done
  </code></pre>
  
  <p>Works when its copy/inserted into the console, but when ran as a shell script, it returns</p>
  
  <pre><code>'/TEST.sh: line 1: syntax error near unexpected token `do
  '/TEST.sh: line 1: `for files in $(find . -maxdepth 1 -type f); do
  </code></pre>
  
  <p>EDIT:</p>
  
  <p>Attempt 2 with #!/bin/sh added to the first line now results</p>
  
  <pre><code>-bash: /oper/text2pdf_TEST.sh: /bin/sh^M: bad interpreter: No such file or directory
  </code></pre>
  
  <p>However /bin/sh does exist</p>
  
  <p>Attempt 3 with #!/bin/bash added to the first line now results</p>
  
  <pre><code>-bash: /oper/text2pdf_TEST.sh: /bin/bash^M: bad interpreter: No such file or directory
  </code></pre>
  
  <p>However /bin/bash does exist</p>