Linux学习笔记之Linux shell脚本运行出现问题:bash: ./test: bin/sh: bad interpreter: No such file or directory

网友投稿 736 2022-08-24

Linux学习笔记之Linux shell脚本运行出现问题:bash: ./test: bin/sh: bad interpreter: No such file or directory

Linux学习笔记之Linux shell脚本运行出现问题:bash: ./test: bin/sh: bad interpreter: No such file or directory

问题:

在Linux系统中使用“vi test.sh”命令创建.sh文件,保存文件(:wq)并赋予权限(chmod +x test.sh)后,执行(./test.sh),出现问题:“bash: ./test: bin/sh: bad interpreter: No such file or directory”。

test.sh文件代码如下:

#!bin/sh

str="hello world"

echo $str

echo "shell,${str}"

解决办法如下:

1、首先检查代码内容,发现由于粗心“#!bin/sh”出错,修改为“#!/bin/sh”,再运行一遍看。

2、其次检查文件的属性,代开文件输入:“:set ff”,可以看到dos或unix的字样。如果的确是dos格式的,那么你可以用set ff=unix把它强制为unix格式的,然后存盘退出,再运行一遍看。

版权声明:本文内容由网络用户投稿,版权归原作者所有,本站不拥有其著作权,亦不承担相应法律责任。如果您发现本站中有涉嫌抄袭或描述失实的内容,请联系我们jiasou666@gmail.com 处理,核实后本网站将在24小时内删除侵权内容。

上一篇:【同行说技术】Python开发、调试、爬虫类工具大全(python爬虫用什么软件编程)
下一篇:Linux基本命令—mkfs/mount/umount/wget/yes/make/passwd
相关文章

 发表评论

暂时没有评论,来抢沙发吧~