相关疑难解决方法(0)

什么是“^M”,我该如何摆脱它?

当我在 Vim 中打开文件时,我看到奇怪的^M字符。

不幸的是,世界上最受欢迎的搜索引擎对查询中的特殊字符表现不佳,所以我在这里问:

  • 这是什么^M性格?

  • 怎么可能到了那里?

  • 我该如何摆脱它?

vim special-characters

245
推荐指数
8
解决办法
33万
查看次数

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

我已经创建了一个 bash 脚本,但是当我尝试执行它时,我得到

#!/bin/bash no such file or directory
Run Code Online (Sandbox Code Playgroud)

我需要运行命令:bash script.sh让它工作。

我怎样才能解决这个问题?

bash executable shell-script shebang

94
推荐指数
4
解决办法
30万
查看次数

shebang 线不适用于 cr-lf

为什么以下基本脚本的 shebang 部分不起作用:

$ cat hello.sh
#! /bin/sh
echo Hello
$ ./hello.sh
bash: ./hello.sh: /bin/sh^M: bad interpreter: No such file or directory

$ cat hello.py
#! /usr/bin/env python3
print("Hello")
$ ./hello.py
: No such file or directory
Run Code Online (Sandbox Code Playgroud)

而手动调用解释器正在工作:

$ sh hello.sh
Hello
$ python3 hello.py
Hello
Run Code Online (Sandbox Code Playgroud)

command-line newlines shebang

10
推荐指数
1
解决办法
2896
查看次数