When executing a script from the path (scriptname, rather than "sh scriptname") I receive the following error:

-bash: ./gitup: /bin/bash/: bad interpreter: Not a directory

All of the other scripts in the same directory execute without issue, and I do not encounter this issue when the script is executed manually (sh scriptname), only when executed by itself. So the script, itself, seems to not be the issue as it does execute normally, and did so until I opened a new shell session and encountered this error for this script alone.

The script is executable, includes all requisite lines to execute in the way I've described (it worked properly until earlier today) and is able to be executed by my user, so I am unsure of what the issue could be.

The shebang line reads #!/bin/bash. I used the command "export PATH=$PATH:repos/utilities " to direct to the directory storing these scripts, all of which, besides this one, execute simply by calling the script name (i.e. gitup).

  • 3
    Could you please include at least the first line (the shebang line) of your script and the command you use to call it? You said it is in your path, yet you call it with ./gitup. Are you sure you are running the script you think you are?
    – terdon
    Jan 28, 2013 at 21:37

2 Answers 2


There are a few things I can think of.

  1. You said your script is in your $PATH, yet you call it with its full path (./gitup as opposed to just gitup). Could it be that you have edited one version of the script (the one in your $PATH, say ~/bin/gitup) and have then executed another (./gitup)?

  2. Could there be multiple versions in your $PATH? You can check with

    which -a gitup
  3. You may have inadvertently entered a strange invisible character while editing the script. Check the shebang line using od:

    head -1 ./gitup | od -c

    Make sure there is nothing after #!/bin/bash but the newline character (\n). It should look like this:

    0000000   #   !   /   b   i   n   /   b   a   s   h  \n
  • Thank you. It looks like there were multiple paths to the same script. Jan 28, 2013 at 22:06
  • I also saw this when file system goes funny. I could read the file ok. Try to move or rename the file. If you see "Stale file handle" error this is your problem.
    – gaoithe
    Sep 21, 2018 at 11:06
  • @gaoithe stale file handle is a completely different error usually related to no longer valid inode values. I don't see how it's relevant here.
    – terdon
    Sep 21, 2018 at 11:10
  • @terdon it's relevant because "/bin/bash/: bad interpreter:" was exactly the error I got when running a script. I could read the script. I could cat it. Permissions looked fine. I just couldn't run it. If I copied the script to new name it ran fine. When I tried to mv or rm the file I saw "Stale file handle" I put my experience here: stackoverflow.com/questions/2841593/bash-script-bad-interpreter/…
    – gaoithe
    Sep 21, 2018 at 14:14
  • 1
    @gaoithe huh, that's interesting. If you see that again, it would be great if you could post a question about it, either here or on Unix & Linux. I find that very surprising and I wonder how it could have happened. Maybe something to do with the fact that it was in a docker container? Odd.
    – terdon
    Sep 21, 2018 at 14:16

Check the shebang (#!) line, make sure that it says


and not


If it looks like the second example, change it to the first.

EDIT(in response to this comment)

If this is limited to only one script, make a copy of this script, and start removing code from it, and make a minimal script that still shows this problem. Then post that minimal script.

  • I thought that at first and verified it was using: #!/bin/bash which is why I'm so baffled by this. Jan 28, 2013 at 21:35
  • @josephmarhee Is /bin/bash a symlink to /bin/bash/? Does /bin/bash exist? Is your system up-to-date (a weird bug)?
    – BenjiWiebe
    Jan 28, 2013 at 21:37
  • It doesn't appear to be symlinked, but /bin/bash does exist; this seems limited to just the one script, but nothing in the script seems to be the issue. I'll run an update and see what comes of it. Thanks. Jan 28, 2013 at 21:41
  • @josephmarhee See my edit
    – BenjiWiebe
    Jan 28, 2013 at 21:44
  • Thank you. I'm going to mess with the script and see what comes of it. It is likely something somewhere in there that got edited at some point, so hopefully it is that. Jan 28, 2013 at 22:00

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .