I have written a program in C and produced an executable from it. I want to use this program from any pwd
. One method is to make its pathname a environment variable using export
. But in this method, everytime I want to invoke my program, I need to prefix my command word with $
. I want my command to work like in-build commands like cat
, grep
, awk
, top
, man
, etc.
Let's say my command is myprog
.
$ myprog arg1 arg2
this command should invoke my executable from any directory as the pwd
in the terminal.
cp myprog ~/bin
, typerehash
to force the shell to rescan the directories in$PATH
. – waltinator Mar 14 '24 at 22:25