4

Possible Duplicate:
Why do we use “./” to execute a file?

It seems redundant and gets annoying after a while -- is there a way to change this? If not, can somebody explain the reasoning behind this?

Thanks!

  • Aren't duplicates flagged here (it does not appear as reson in the list). Should I ask this on meta? Okay - I will do so! – user unknown Jul 04 '11 at 10:11

3 Answers3

6

You don't, if the current directory is in your path and there isn't another executable with the same name in a directory named earlier in the path. If either of these conditions isn't true, ./ effectively says "look here".

Although you can add "." to your path, it isn't advisable, since that opens the door for unexpected (or malicious) results if you execute a command from a directory that has executables that match the name of system commands.

TomG
  • 249
0

You do if your current directory is not in your path. If you ever log in as root or are a sudoer, I do not recommend you add your current directory to your path. Just put up with the ./

If you wish, make a directory in your home directory called bin. Then add this directory to your search path. It's a good place to put your general purpose housekeeping scripts.

0

isnt it much easier than running your program using sh yourprogram.sh or python yourprogram.py ?

afbr1201
  • 4,759