Some of my bash scripts were not running with the following error:
$ ./test-script.sh -bash: ./test-script.sh: /bin/bash^M: bad interpreter: No such file or directory
After some googling, it turned out that on Linux host script files should have a specific line break(LF), and using default Windows (CRLF) is not supported.
How to fix:
1. Notepad ++ replace CRLF to LF
To see end line character: “View -> Show Symbol -> Show End of Line”To replace CR LF to LF:
- Find what:\r\n
- Replace: \n
- Search Mode = Regular expression
- Replace All
2. VIM replace CRLF to LF
:set ff=unix :wq!
You must be logged in to post a comment.