Replace CRLF to LF in bash script - Kote

Replace CRLF to LF in bash script

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:

  1.  Find what:\r\n
  2. Replace: \n
  3. Search Mode = Regular expression
  4. Replace All

2. VIM replace CRLF to LF

:set ff=unix
:wq!