/bin/bash^M: bad interpreter

While trying to run a bash script I get the following error :/bin/bash^M: bad interpreter

Warning: I did edit the file in Windows with notepad.

If there a fix for this?

Thanks
LVL 2
jculkincysAsked:
Who is Participating?
 
JohnK813Commented:
Linux and Windows handle the carriage return/line feed at the end of a line differently.  So, if you edit a file in Windows and then go back to Linux, you will find a ^M added to the end of each line.  There are a couple of ways to get rid of this:

If you have it, use the command dos2unix:
dos2unix yourscript.sh > yourscript2.sh

Using sed:
sed -e "s/^M//g" yourscript.sh > yourscript2.sh

In vi:
http://www.vim.org/tips/tip.php?tip_id=26

(Is this John Culkin from Scranton, PA?)
0
 
jculkincysAuthor Commented:
It sure is me.

Is this John Kanka aka webmaster of the greatest website in the world (http://kankasports.blogspot.com/ ) aka my idol

You are truly an EXPERT!!!
0
 
JohnK813Commented:
Why, it sure is me too.  I was wondering when I would run into someone I knew on here....

Are you dabbling in Linux for work or for fun?
0
 
jculkincysAuthor Commented:
Both - I am a sysadmin now - or at least thats what boss claims.

I dig bash and wish I was better at it
0
 
JohnK813Commented:
Nice.

I'm stuck in a Windows environment, but I'd probably let batch files and VBS scripts do my entire job if I could get away with it.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.