/bin/bash^M: bad interpreter

Posted on 2006-04-24
Last Modified: 2008-01-09
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?

Question by:jculkincys
    LVL 14

    Accepted Solution

    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 >

    Using sed:
    sed -e "s/^M//g" >

    In vi:

    (Is this John Culkin from Scranton, PA?)
    LVL 2

    Author Comment

    It sure is me.

    Is this John Kanka aka webmaster of the greatest website in the world ( ) aka my idol

    You are truly an EXPERT!!!
    LVL 14

    Expert Comment

    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?
    LVL 2

    Author Comment

    Both - I am a sysadmin now - or at least thats what boss claims.

    I dig bash and wish I was better at it
    LVL 14

    Expert Comment


    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.

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Enabling OSINT in Activity Based Intelligence

    Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

    How many times have you wanted to quickly do the same thing to a list but found yourself typing it again and again? I first figured out a small time saver with the up arrow to recall the last command but that can only get you so far if you have a bi…
    Little introduction about CP: CP is a command on linux that use to copy files and folder from one location to another location. Example usage of CP as follow: cp /myfoder /pathto/destination/folder/ cp abc.tar.gz /pathto/destination/folder/ab…
    Learn how to get help with Linux/Unix bash shell commands. Use help to read help documents for built in bash shell commands.: Use man to interface with the online reference manuals for shell commands.: Use man to search man pages for unknown command…
    Learn how to navigate the file tree with the shell. Use pwd to print the current working directory: Use ls to list a directory's contents: Use cd to change to a new directory: Use wildcards instead of typing out long directory names: Use ../ to move…

    737 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    23 Experts available now in Live!

    Get 1:1 Help Now