macos – How to solve bad interpreter: No such file or directory

macos – How to solve bad interpreter: No such file or directory

Remove ^M control chars with

perl -i -pe y|r||d script.pl

/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

macos – How to solve bad interpreter: No such file or directory

You seem to have weird line endings in your script: ^M is a carriage return r. Transform your script to Unix line endings (just n instead of rn, which is the line ending on Windows systems).

Leave a Reply

Your email address will not be published.