报错:/root/xxx.shell: 行19: $‘\r’: 未找到命令
原因:
脚本由windows上传至Linux服务器,windows的换行符为"/r/n",而unix的换行符为"/n" 从而导致不识别
解决方案:
方法1. 直接再Linux中执行这个
sed -i 's/\r$//' xxx.shell
方法2.用vim打开shell脚本(vi xxx.shell),执行以下命令
:set ff=unix #转换为unix格式
:wq #保存、退出
方法3. 安装dos2unix,并转换
安装dos2unix。
#yum install dos2unix
使用dos2unix对脚本转换。
#dos2unix xxx.sh