How to solve “bad interpreter: No such file or directory”

前端 未结 6 1255
礼貌的吻别
礼貌的吻别 2021-01-31 08:12

I\'m trying to run a sh script and get the following error on Mac:

/usr/bin/perl^M: bad interpreter: No such file or directory

How

6条回答
  •  不思量自难忘°
    2021-01-31 08:51

    The problem is that you're trying to use DOS/Windows text format on Linux/Unix/OSX machine.

    In DOS/Windows text files a line break, also known as newline, is a combination of two characters: a Carriage Return (CR) followed by a Line Feed (LF). In Unix text files a line break is a single character: the Line Feed (LF).

    Dos2unix can convert for you the encoding of files, in example:

    dos2unix yourfile yourfile
    

    For help, run: man dos2unix.

提交回复
热议问题