I’m running OSX 10.6, and I have this very simple script in a file “hi.sh”:
#!/bin/bash
echo "hi"
I’ve already run “chmod +x hi.sh”. Now, I’ve tried both of the following:
$ ./hi.sh
$ bash hi.sh
and neither outputs “hi”. What could be the problem?
It could be that you used an editor that defaults to
\ras line separator, which was the separator used under classic (pre OS X) MacOS. Trywc -l hi.sh; if you get 0 lines, then it’s a line ending problem. Your script would then be just a single comment line, which would of course do nothing.