简体   繁体   English

!#/ bin / bash:没有这样的文件或目录

[英]!#/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.

相关问题 /usr/bin/bash: 没有这样的文件或目录 - /usr/bin/bash: No such file or directory “ / bin / bash cd〜”显示为“ / bin / bash:cd:没有这样的文件或目录”,为什么? - “/bin/bash cd ~” results in “/bin/bash: cd: No such file or directory”, why? 使用#!bin / bash文件更改目录和运行命令 - change directory and run command with #!bin/bash file / bin / bash ^ M:错误的解释器:没有这样的文件或目录 - /bin/bash^M: bad interpreter: No such file or directory -bash: /usr/bin/virtualenvwrapper.sh: 没有那个文件或目录 - -bash: /usr/bin/virtualenvwrapper.sh: No such file or directory gradlew 错误:/usr/bin/env: bash: No such file or directory - Error with gradlew: /usr/bin/env: bash: No such file or directory bash:bin / hadoop:没有这样的文件或目录(ubuntu 16.04上的hadoop 2.7.3) - bash: bin/hadoop: No such file or directory(hadoop 2.7.3 on ubuntu 16.04) -bash: /usr/bin/yum: /usr/bin/python: bad interpreter: 没有那个文件或目录 - -bash: /usr/bin/yum: /usr/bin/python: bad interpreter: No such file or directory 从Cron作业执行bash脚本时出现“ / bin / bash ^ M:错误的解释器:没有这样的文件或目录”错误 - “/bin/bash^M: bad interpreter: No such file or directory” error when executing a bash script from a cron job bash中的十六进制到bin文件转换 - hex to bin file conversion in bash
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM