SittingBull SittingBull - 3 months ago 7
Bash Question

How do I execute my program without ./a.out command?

I have written a c program. I want to pipe the program and I want to make it look meaningful. So instead of writing

each time, I want to name it
. To achieve that, I compiled my program following way:
gcc -o changetext myprog.c
. To the best of my knowledge, this should replace the use of
should do that instead. But I'm getting
command not found
. I am new to c and unix environment. Any suggestion appreciated.


As I said in a comment, you can either put a dot slash (./) in front of the executable to run it


Or you put in in a directory that is referenced in the PATH environment variable. A nice explanation of this safety feature can be found here (thanks to rubenvb):

It says that this is more or less to distinguish built-in commands from user-written commands with the same name. I am not convinced though. The shell could simply prefer built-in names to user-supplied ones, and look in the current directory as well as in the PATH.

But this is the *nix way.