VoodooChild92
VoodooChild92

Reputation: 2053

Making a executable into a shell command using a C program

I've a executable named say "sortx". Now I want to write a C program which transforms this executable into a shell command.

ex: ./sortx numbers.txt

After running the C program on "sortx" what I want is :

sortx numbers.txt

Upvotes: 3

Views: 332

Answers (3)

rahool
rahool

Reputation: 639

Add the directory in which sortx is present to $PATH. This way you could execute your program locally, like,

sortx numbers.txt

To add directory ~/my_bin to the beginning of the $PATH environment variable, add or update this in your .bash_profile:

PATH=~/my_bin:$PATH

Upvotes: 6

megubyte
megubyte

Reputation: 1579

On Linux to make any script or program globally executable (e.g "sortx" rather than "./sortx") you can put the script in wither /usr/bin or /bin -- I prefer /usr/bin :)

Upvotes: 3

Related Questions