How to solve "bad interpreter: No such file or directory"

Elad Benda picture Elad Benda · Jun 16, 2013 · Viewed 90.7k times · Source

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 can I fix this?

Answer

mpapec picture mpapec · Jun 16, 2013

Remove ^M control chars with

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