今天将Windows下编译好的 test.sh文件上传到Linux下。
用命令:chmod +x test.sh
编译运行之后一直报错,提示我:
-bash: ./test.sh: /bin/bash^M: bad interpreter: No such file or directory
开始是说我权限不够, 不能执行, 接着我就把权限给改了, 就一直报上面问题.
出现上面错误的原因之一是脚本文件是DOS格式的, 即每一行的行尾以\r\n来标识, 使用vim编辑器打开脚本, 运行:
:set ff?
可以看到DOS或UNIX的字样. 使用set ff=unix把它强制为unix格式的, 然后存盘退出, 即可.
linux下执行.sh文件总是提示permission denied:http://www.linuxdiyf.com/linux/15863.html
linux下执行.sh文件的方法和语法:http://www.linuxdiyf.com/linux/13698.html
Linux下执行.sh文件提示No such file or directory:http://www.linuxdiyf.com/linux/6017.html