• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1185
  • Last Modified:

/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
0
jculkincys
Asked:
jculkincys
  • 3
  • 2
1 Solution
 
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

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now