linux 执行脚本出现如下错误:
***.sh: line 2: $'\r': command not found
***.sh: line 4: $'\r': command not found
***.sh: line 8: $'\r': command not found
***.sh: line 12: $'\r': command not found
***.sh: line 18: syntax error near unexpected token `elif'
***.sh: line 18: ` elif [ "..." ]; then
google出的解决方法(对.sh文件中内容进行替换):
sed -i -e 's/\r$//' ***.sh
原文链接:
网上说的在notepad++中打开所有的回车换行都是windows的CR LF,然而我的打开本来就是unix的LF方式,所以不是这个问题。使用dos2unix等工具不知道可不可以解决,感觉太复杂。