Why do you need ./ (dot-slash) before executable or script name to run it in bash?

前端 未结 9 919
耶瑟儿~
耶瑟儿~ 2020-11-22 03:59

When running scripts in bash, I have to write ./ in the beginning:

$ ./manage.py syncdb

If I don\'t, I get an error message:

9条回答
  •  礼貌的吻别
    2020-11-22 04:52

    This question already has some awesome answers, but I wanted to add that, if your executable is on the PATH, and you get very different outputs when you run

    ./executable
    

    to the ones you get if you run

    executable
    

    (let's say you run into error messages with the one and not the other), then the problem could be that you have two different versions of the executable on your machine: one on the path, and the other not.

    Check this by running

    which executable

    and

    whereis executable
    

    It fixed my issues...I had three versions of the executable, only one of which was compiled correctly for the environment.

提交回复
热议问题