在Linux系统中,运行Shell脚本,出现了$'\r': command not found错误
可能因为该Shell脚本是在Windows系统编写时,每行结尾是\r\n
而在Linux系统中行每行结尾是\n
在Linux系统中运行脚本时,会认为\r是一个字符,导致运行错误
使用dos2unix 转换一下就可以了
dos2unix <文件名>
# dos2unix: converting file one-more.sh to Unix format ...
如果出现:
-bash: dos2unix: command not found
就是还没安装,安装一下就可以了
sudo apt install dos2unix
谢谢