Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have bash script which does nothing special:

echo Hello!

If I run it like this ., it works.

kopparberg:dev marek$ .

If I run it like this ./, it does not.

kopparberg:dev marek$ ./ 
-bash: ./ /bin/bash^M: bad interpreter: No such file or directory

What is the difference?

share|improve this question
up vote 5 down vote accepted

The difference between sourcing (. the script and running it ( or ./ is in the first line.

If you source the script the first line is only a comment and ignored. But if you run it, the first line is examined by the kernel for the first two characters, and if they are "#!", the rest of the line will be used as the path and the first argument for an interpreter. That is the kernel will look for an executable named /bin/bash and pass it the name of the script as first argument. Like this: /bin/bash ./

This is what normally would happen and you are right, it should have the same effect for your script. But your script contains a problem: The first line ends with a DOS line ending (CR LF) instead of a unix line ending (LF). So the name of the interpreter, as the kernel sees it is /bin/bash^M which does not exist on your disk (^M stands for the spurious CR before the line ending). To make matters worse, the ^M character is usually invisible.

You can prove that this is the case with cat -v (which prints the substitution ^M for the invisible CR character).

share|improve this answer

The fist solution is an alias for "source" command.

The shebang is considered like a #comment for source

When you call the script with ./script, the shell will execute the script with the shebang #!/bin/bash

The error you gave seems to be a CRLF problem, you can run :


to remove Windows end-lines.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.