[英]!#/bin/bash: No such file or directory
First, I run 首先,我跑
/bin/bash a.sh
It succeed. 它成功了。
But when I want to run 但是当我想跑的时候
/bin/bash a.sh > a_info.txt
It failed. 它失败了。
Error: line 1: !#/bin/bash: No such file or directory
It does not seem that it's ' ^M
' that's causing this error. 它似乎不是“
^M
”导致此错误。
The shebang pattern is #!/bin/your_shell
, not !#/bin/your_shell
. shebang模式是
#!/bin/your_shell
,而不是!#/bin/your_shell
。 Just fix the typo. 只是修复错字。
Check the file's encoding. 检查文件的编码。
If you get this error, but you did not misspell the 'shebang', have a close look at the file's encoding. 如果你收到这个错误,但你没有拼错'shebang',请仔细查看文件的编码。 I was getting this error on a file with encoding 'UTF8 with BOM'... I guess the BOM (Byte Order Mark) was causing the problem.
我在编码'带有BOM的UTF8'的文件上收到此错误...我猜BOM(字节顺序标记)导致了问题。 Changed the encoding to ASCII and that fixed it (or you can use 'UTF-8 without BOM' which is effectively the same for files only containing ASCII characters).
将编码更改为ASCII并修复了它(或者您可以使用'无BOM的UTF-8',这对于仅包含ASCII字符的文件实际上是相同的)。
如果您的shell脚本使用CRLF而不是LF行结尾,则“无此类文件或目录”错误的另一个可能原因是。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.