$'\r': command not found
问题描述
用 Pycharm 写.sh
脚本,在Linux远程服务器上运行的时候报错
问题分析
https://stackoverflow.com/questions/5230798/r-character-in-shell-script
Your problem is that the file has Windows line endings. This can be caused by editing a file in Windows and trying to run it on a non-Windows system.
意思是文件是Windows系统的结尾符。
解决方法
安装dos2unix
包,转换文件,然后再运行脚本
sudo apt install dos2unix # 下载dos2unix,一般需要root权限
dos2unix YourFile.sh # 转换文件
bash YourFile.sh
即可正常运行脚本