linux - 无法在树莓派 (raspbian) 上执行简单的 bash 脚本

标签 linux bash

好的,基本上我已经通过在终端中输入 bin 并输入来创建脚本

sudo nano mytesterscript.sh

从那里我写了脚本并保存了它。 为了使其可执行,然后我使用了命令

    chmod +x mytesterscript.sh

然后当我想用

来执行它的时候
./mytesterscript.sh

我得到错误:

bin/bash: bad interperter:no such file or directory

我可以通过输入来执行脚本

bash mytesterscript.sh

但我希望能够做到这一点

./mytesterscript.sh

有什么想法吗?

#!bin/bash
#declare $STRING Variable
STRING= "Hello world"
#print variable on screen
echo $STRING

最佳答案

确保脚本的顶部显示:

#!/bin/bash

观察bin前面的/

如果这不起作用,请尝试 which bash 并使用该输出。

关于linux - 无法在树莓派 (raspbian) 上执行简单的 bash 脚本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23793171/

相关文章:

c - 如何在C中制作定时器?

bash - 新 Bash session 的多个初始化文件

linux - 用于递归列出包含具有特定扩展名的文件的文件夹中的所有子目录的 Shell 脚本

linux - struct load_info 中的字段strmap 是什么意思?

linux - 如何在 hostgator vps 主机上的 chat.mydomain.com 上安装 node.js 服务器?

linux - 运行远程命令后 ssh session 不会关闭

bash - 通过shell脚本转义美元符号字符串

regex - 在 bash 中使用正则表达式提取版本

linux - sh 不支持进程替换 <(...) 吗?

linux - grep 操作后无法正确保存屏幕输出