主要原因是build.sh是在windows下编辑然后上传到linux系统里执行的。.sh文件的格式为dos格式。而linux只能执行格式为unix格式的脚本。

我们可以通过vi编辑器来查看文件的format格式。步骤如下:

1.首先用vi命令打开文件

2.在vi命令模式中使用

:set ff 

可以看到改文件的格式为dos

3.修改文件format为unix

方法一:使用vi修改文件format

命令:set ff=unix

:set ff=unix

执行完后再通过set ff命令查看文件格式,结果如下:

然后执行 ./build.sh就不回报错了。

linux 下 shell脚本报错:-bash: ./build.sh: /bin/sh^M: bad interpreter: No such file or directory的更多相关文章

  1. shell脚本报错:-bash: xxx: /bin/bash^M: bad interpreter: No such file or directory

    当我们把文件从windows系统中编辑的文件拷贝到linux系统中,如果我们执行文件会保存如下的错: shell脚本报错:-bash: xxx: /bin/bash^M: bad interprete ...

  2. shell脚本报错:"[: =: unary operator expected"

    shell脚本报错:"[: =: unary operator expected" 在匹配字符串相等时,我用了类似这样的语句: if [ $STATUS == "OK&q ...

  3. window下编写python脚本在linux下运行出错 usr/bin/python^M: bad interpreter: No such file or directory

    今天在windows下使用notepad++写了个python脚本,传到linux服务器执行后提示:-bash: ./logger.py: usr/bin/python^M: bad interpre ...

  4. nagios监控客户端报错/usr/bin/perl^M: bad interpreter: No such file or directory

    nagios服务端监控客户端内存时发现监控不上 在客户端直接执行脚本,报错如下: # /usr/local/nagios/libexec/check_memory.pl -w 6% -c 3% -ba ...

  5. Linux shell 脚本报错:/bin/bash^M: bad interpreter: No such file or directory

    今天遇到一个很诡异的问题,一直运行很正常的shell脚本失败了,只是昨天增加了一个参数而已. 报错信息: /bin/bash^M: bad interpreter: No such file or d ...

  6. Shell脚本报错:-bash: ./switch.sh: /bin/bash^M: bad interpreter: No such file or directory

    在学习shell中测试case参数命令代码如下 #!/bin/bash #switch测试 case $1 in     start)         echo 'start'     ;;      ...

  7. shell脚本报错:-bash: xxx: /bin/sh^M: bad interpreter: No such file or directory

    今天执行一个shell脚本,然后在执行的时候报错,脚本内容很简单,仅供测试: #!/bin/sh echo "test shell " 具体报错信息如下 [root@localho ...

  8. shell脚本报错:.sh: /bin/bash^M: 坏的解释器: 没有那个文件或目录

    .sh: /bin/bash^M: 坏的解释器: 没有那个文件或目录 这是因为shell脚本是Windows下编辑的 格式不一样 执行 sed -i 's/\r$//' 脚本名称.sh

  9. CRLF line terminators导致shell脚本报错:command not found

    Linux和Windows文本文件的行结束标志不同.在Linux中,文本文件用"/n"表示回车换行,而Windows用"/r/n"表示回车换行.有时候在Wind ...

随机推荐

  1. SSM项目的搭建

    本文示例在如下环境下搭建一个Maven+Druid+SSM+Shiro+Mysql+PageHelper以及Mybatis Generator反向生成代码的项目 附上GitHub地址:https:// ...

  2. 【软工实践】Alpha冲刺(4/6)

    链接部分 队名:女生都队 组长博客: 博客链接 作业博客:博客链接 小组内容 恩泽(组长) 过去两天完成了哪些任务 描述 学习调用中国天气网API,接近实现天气推送功能 对天气推送的形式进行讨论及重确 ...

  3. windows正常,linux报错:'PHPExcel_Reader_excel2007' not found

    原因:因为在linux下,大小写敏感 我的文件夹命名是大写,在window小写可以访问到,但是在linux就大小写敏感导致没找到文件没导入成功 导入文件的路径(错误)import('phpexcel. ...

  4. Nacos学习

    Nacos是阿里开源的一个新框架,在分布式的架构中,Nacos同时扮演着服务注册中心和配置中心的角色.今天主要讲的是Nacos作为服务注册中心. 分布式中著名的CAP理论,任何一种服务注册中心都只能实 ...

  5. 最近b站好像把blv格式换成m4s,改成mp4之后没有声音,

    我研究了几个小时,然后知道一个方法,但是必须有电脑.1.m4s 的视频改为mp4可以拖进pr2.m4s的音频不能直接拖进pr(会报错),改为mp3也一样,要先改为mp3,然后在格式工厂里面选择,mp3 ...

  6. Android 解读Event和Main Log

    1 Android P EventLogTags文件 Android P 9.0.0 所有EventLogTags文件List: system/bt/EventLogTags.logtags syst ...

  7. 案例:使用BeautifuSoup4的爬虫

    使用BeautifuSoup4解析器,将招聘网页上的招聘单位名称存储出来.其他信息可类似爬取即可 # -*- coding:utf-8 -*- from bs4 import BeautifulSou ...

  8. 运行 puppeteer 报错 chrome: error while loading shared libraries: libpangocairo-1.0.so.0: cannot open shared object file: No such file or directory

    运行 puppeteer 报错 chrome: error while loading shared libraries: libpangocairo-1.0.so.0: cannot open sh ...

  9. (转)关于sql和MySQL的语句执行顺序(必看!!!)

    原文:https://blog.csdn.net/u014044812/article/details/51004754 https://blog.csdn.net/j080624/article/d ...

  10. c++ stl bind函数介绍

    /* stl::bind 使用 */ #include <iostream> #include <string> #include <functional> /* ...