Mar 6, 2012 at 3:40am UTC
i'm on ubuntu and i just wanna know why i need to to type the "./" before and object file to run it?
for example "g++ pop.cpp -o pop"
i need to type "./pop" to run it. why do i need to type the "./"?
Mar 6, 2012 at 3:58am UTC
. is basically shorthand for the current directory path, so ./pop is /current/directory/path/pop
Mar 6, 2012 at 5:37am UTC
but why would i need the / then? actually why would i need the ./ are all if i am already in the directory where pop is?
Mar 6, 2012 at 5:54am UTC
I believe the shell first checks built in commands then directories in your PATH, unless your current directory is in your PATH it wont be checked. If you omit the / what the shell interprets is /current/directory/pathpop
Mar 6, 2012 at 6:22am UTC
It's a security measure to prevent a program with the name of a common command in the current directory to be accidentally run instead of the actual command.