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

问题:

When running scripts in bash, I have to write ./ in the beginning:在 bash 中运行脚本时,我必须在开头写./

$ ./manage.py syncdb

If I don't, I get an error message:如果我不这样做,我会收到一条错误消息:

$ manage.py syncdb
-bash: manage.py: command not found

What is the reason for this?这是什么原因? I thought .我想. is an alias for current folder, and therefore these two calls should be equivalent.是当前文件夹的别名,因此这两个调用应该是等效的。

I also don't understand why I don't need ./ when running applications, such as:我也不明白为什么我在运行应用程序时不需要./ ,例如:

user:/home/user$ cd /usr/bin
user:/usr/bin$ git

(which runs without ./ ) (没有./运行)


解决方案:

参考一: https://en.stackoom.com/question/QZ07
参考二: https://stackoom.com/question/QZ07
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章