Centos7下执行shell脚本报错如下
[root@ip-172-29-10-16 ~]# sh install_zabbix_agent.sh install_zabbix_agent.sh: line 2: $'\r': command not found install_zabbix_agent.sh: line 8: $'\r': command not found install_zabbix_agent.sh: line 9: $'\r': command not found install_zabbix_agent.sh: line 10: syntax error near unexpected token `$'{\r'' 'nstall_zabbix_agent.sh: line 10: `install_zabbix(){
原因
这是因为脚本文件可能在window弄过,有window下的空行,把他转换成unix格式的就行
解决办法
yum install dos2unix
然后再执行这个脚本就可以了
来源:https://www.cnblogs.com/lemon-le/p/10552581.html