bash:$'\r': command not foundbash
形成这个问题的缘由是Windows环境下换行的“\r”到了Linux环境下不可以识别了,由于Linux环境下默认的换行符为“\n”,咱们只须要把文件转成unix就好。使用 dos2unix 工具实现该转换。工具
# 1.安装 dos2unix 工具 [root@localhost ~]# apt install dos2unix # Ubuntu系统 [root@localhost ~]# yum -y install dos2unix # Centos系统 # 2.转换文件 [root@localhost ~]# chmod 755 test.sh [root@localhost ~]# dos2unix test.sh # 3.再次执行文件就能够啦 [root@localhost ~]# sh ./test.sh