从Windows上传了一个shell脚本到Linux上,运行时出现syntax error near unexpected token `do的错误,后来遇到/bin/bash^M: bad interpreter:的错误
原来是由于Windows中使用了Ctrl+C Ctrl+V,导致出现了^M符号,该符号是换行的意思
具体解决方式有两种:
①vi编辑该文件,:set fileformat=unix
②安装dos2unix, dos2unix filename.sh
参考:http://stackoverflow.com/questions/2920416/configure-bin-shm-bad-interpreter