What is bin bash M bad interpreter no such file or directory?

What is bin bash M bad interpreter no such file or directory?

/bin/bash^M: bad interpreter: No such file or directory ^M is a character used by Windows to mark the end of a line (so it is a carriage return) and that matches the CR character. Basically we are faced with a line termination used by Windows in a Linux script, of course this is confusing.

How do I get rid of M bad interpreter?

You can do it with the following command:

  1. sed -i -e ‘s/\r$//’ NAME-OF-FILE. sh.
  2. dos2unix NAME-OF-FILE. sh.
  3. sudo apt-get install dos2unix. To convert the file back to DOS formatting, you cna use the unix2dos command.
  4. vi NAME-OF-FILE. sh.
  5. :set ff=unix. Then write the file and close it using the following command:
  6. :wq!

What does M mean in bash?

The ^M is a carriage-return character. If you see this, you’re probably looking at a file that originated in the DOS/Windows world, where an end-of-line is marked by a carriage return/newline pair, whereas in the Unix world, end-of-line is marked by a single newline. ^MThe second line.

How do I convert dos2unix?

dos2unix is a tool to convert text files from DOS line endings (carriage return + line feed) to Unix line endings (line feed). It is also capable of conversion between UTF-16 to UTF-8. Invoking the unix2dos command can be used to convert from Unix to DOS.

How do I write a bash script?

Quick guide to writing a bash script on the Mac/Linux command-line 1. Open a new file 2. Write the shebang line: 3. Write script contents. 4. Make the script executable 5. Run the script 6. Add an input variable 7. Now run it: 8. Add an optional input variable 9. Now run it again:

How do you change directory in Bash?

Open Git Bash directly in the folder. Changing directory through opening it in the same folder is quite straight forward. For this, go to the directory to which you want to change the directory in a normal way you explore your system. After this, right click anywhere in the directory => Open Git Bash here.

What is a bash interpreter?

Bash is an interpreter according to the GNU Bash Reference Manual: Bash is the shell, or command language interpreter, for the GNU operating system .