美文网首页Java
/bin/bash^M: 坏的解释器: 没有那个文件或目录

/bin/bash^M: 坏的解释器: 没有那个文件或目录

作者: 一觉睡到丶小时候 | 来源:发表于2020-03-25 09:55 被阅读0次

问题描述

在安装完成gitblit之后,运行gitblit.sh文件时报错

[root@localhost gitblit-1.9.0]# ./gitblit.sh 
-bash: ./gitblit.sh: /bin/bash^M: 坏的解释器: 没有那个文件或目录

错误原因

这个文件在Windows 下编辑过,在Windows下每一行结尾是\n\r,而Linux下则是\n,所以才会有 多出来的\r。

修改错误

使用指令sed -i 's/\r$//' xxxxxxx.sh,上面的指令会把 xxxxxxx.sh 中的\r 替换成空白!

实际操作一下

[root@localhost gitblit-1.9.0]# sed -i 's/\r$//' gitblit.sh 
[root@localhost gitblit-1.9.0]# ./gitblit.sh 
[root@localhost gitblit-1.9.0]# ps aux|grep gitblit.jar
root     26531  0.0  0.0 112724   996 pts/1    R+   09:50   0:00 grep --color=auto gitblit.jar

个人博客
腾讯云社区
掘金
CSDN
公众号:

wx.jpg

相关文章

网友评论

    本文标题:/bin/bash^M: 坏的解释器: 没有那个文件或目录

    本文链接:https://www.haomeiwen.com/subject/esqtuhtx.html