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

前端 未结 9 1046
耶瑟儿~
耶瑟儿~ 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

    Your script, when in your home directory will not be found when the shell looks at the $PATH environment variable to find your script.

    The ./ says 'look in the current directory for my script rather than looking at all the directories specified in $PATH'.

提交回复
热议问题