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

前端 未结 6 1266
礼貌的吻别
礼貌的吻别 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:43

    /usr/bin/perl^M:

    Remove the ^M at the end of usr/bin/perl from the #! line at the beginning of the script. That is a spurious ASCII 13 character that is making the shell go crazy.

    Possibly you would need to inspect the file with a binary editor if you do not see the character.

    You could do like this to convert the file to Mac line-ending format:

    $ vi your_script.sh
    

    once in vi type:

     :set ff=unix
    
     :x
    

提交回复
热议问题