very simple OSX bash script: echo gives no output
I'm running OSX 10.6, a开发者_如何学编程nd 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 \r
as line separator, which was the separator used under classic (pre OS X) MacOS. Try wc -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.
精彩评论