linux 下 shell脚本报错:-bash: ./build.sh: /bin/sh^M: bad interpreter: No such file or directory
主要原因是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的更多相关文章
- shell脚本报错:-bash: xxx: /bin/bash^M: bad interpreter: No such file or directory
当我们把文件从windows系统中编辑的文件拷贝到linux系统中,如果我们执行文件会保存如下的错: shell脚本报错:-bash: xxx: /bin/bash^M: bad interprete ...
- shell脚本报错:"[: =: unary operator expected"
shell脚本报错:"[: =: unary operator expected" 在匹配字符串相等时,我用了类似这样的语句: if [ $STATUS == "OK&q ...
- 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 ...
- 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 ...
- Linux shell 脚本报错:/bin/bash^M: bad interpreter: No such file or directory
今天遇到一个很诡异的问题,一直运行很正常的shell脚本失败了,只是昨天增加了一个参数而已. 报错信息: /bin/bash^M: bad interpreter: No such file or d ...
- 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' ;; ...
- shell脚本报错:-bash: xxx: /bin/sh^M: bad interpreter: No such file or directory
今天执行一个shell脚本,然后在执行的时候报错,脚本内容很简单,仅供测试: #!/bin/sh echo "test shell " 具体报错信息如下 [root@localho ...
- shell脚本报错:.sh: /bin/bash^M: 坏的解释器: 没有那个文件或目录
.sh: /bin/bash^M: 坏的解释器: 没有那个文件或目录 这是因为shell脚本是Windows下编辑的 格式不一样 执行 sed -i 's/\r$//' 脚本名称.sh
- CRLF line terminators导致shell脚本报错:command not found
Linux和Windows文本文件的行结束标志不同.在Linux中,文本文件用"/n"表示回车换行,而Windows用"/r/n"表示回车换行.有时候在Wind ...
随机推荐
- (转载)golang 整数常量INT_MAX INT_MIN最大值最小值
转载地址:https://blog.csdn.net/bdss58/article/details/78388858 在C语言中,有标准库limits.h定义了一些最大最小值常量,例如int类型的最大 ...
- 集成了SSM框架的系统怎么做测试?
1.首先在测试文件夹下新建一个测试基类BaseTest BaseTest中的代码如下: package wbl_ssm_blog.mapper; import org.junit.Test; impo ...
- Mac php 装imagick扩展 菜鸟教程
1.2.直接brew install imagemagick@6完成安装 2.去http://pecl.php.net/package/imagick下载安装包 2.1.下载完后解压tar -xzvf ...
- CSS MDN - 选择器与样式化文字
- 【448】NLP, NER, PoS
目录: 停用词 —— stopwords 介词 —— prepositions —— part of speech Named Entity Recognition (NER) 3.1 Stanfor ...
- [LeetCode] 437. Path Sum III 路径和 III
You are given a binary tree in which each node contains an integer value. Find the number of paths t ...
- GitLab数据备份与恢复
创建备份 $ sudo gitlab-rake gitlab:backup:create 执行完备份命令后会在/var/opt/gitlab/backups目录下生成备份后的文件,如150080913 ...
- 【神经网络与深度学习】【计算机视觉】Fast R-CNN
转自:https://zhuanlan.zhihu.com/p/24780395?refer=xiaoleimlnote 首先声明:本文很多内容来自两个博客: RCNN, Fast-RCNN, Fas ...
- Java开发笔记(一百三十一)Swing的列表框
前面介绍了选择框的用法,当时为了方便用户勾勾点点,无论是复选框还是单选按钮,统统把所有选项都摆在界面上.倘若只有两三个选项还好办,要是选项数量变多比如超过五个,这么多的选择框一齐在界面罗列,不光程序员 ...
- C++ 读取一个文件下所有文件的文件名
Windows: #include<iostream> #include<string> #include <io.h> void readFileNameInDi ...