shell脚本执行错误:#!/bin/bash: No such file or directory

时间:2021-04-12 22:19:54   收藏:0   阅读:43

1、问题描述:

执行.sh脚本时控制台报错 : #!/bin/bash: No such file or directory
 

2、解决办法:

cat -A 文件路径
会发现第一行有问题
M-oM-;M-?#!/bin/bash$
#----------------------------------$
#$
#  M-eM-^PM-/M-eM-^JM-(M-hM-^DM-^ZM-fM-^\M-,;$
#$
#----------------------------------$
phpscriptDir=/Data/code/yoho-chat$

会发现时utf-8格式编码的问题

用notepad++或者UE 转行成unix下文件
并且将文件编码格式换成utf-8 无BOM编码
这样执行就没有问题了
#Linux上面使用dos2unix可以转换编码格式
[root@tse ~]# yum install -y dos2unix
#使用dos2unix转换格式 [root@tse
~]# dos2unix tse.sh

原文:https://www.cnblogs.com/Sungeek/p/14650284.html

评论(0
© 2014 bubuko.com 版权所有 - 联系我们:wmxa8@hotmail.com
打开技术之扣,分享程序人生!