In UNIX File System, all your inbuilt commands are binaries (programs) written to perform certain tasks. ls
command does the listing of directories, mv
command moves or renames files etc.
All these binaries are stored in your /usr/bin
directory. And the path to that directory is stored in your PATH environment variable.
If you have many scripts that do certain tasks, I would recommend them to move in one folder. say for example, /yourname/scripts
and then set this path in your PATH variable.
PATH variable can be set in your .bashrc or .bash_profile file which gets loaded up whenever you fire a terminal session. You can view your PATH variable settings by doing an echo
on it.
[jaypal~]$ echo $PATH
/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/X11/bin:/usr/local/git/bin:/usr/local/mysql/bin:/Developer/usr/bin:/usr/local/ActivePerl-5.12/bin:/Library/Ruby/Site/1.8/rubygems:/Library/Ruby/Gems/1.8/gems/wkpdf-0.5.3-universal-darwin/bin:/Library/Ruby/Gems/1.8/gems/wkpdf-0.5.3-universal-darwin/lib
In your .profile file, simply add :/yourname/scripts
folder and do . .profile
on your shell prompt. This will force your current session to load your profile file without having to quit and log in again.
Once the .profile file has been loaded, you can run your script from anywhere by simply typing scriptname
options or other arguments as needed.
This tutorial will be helpful to you.
/B
and executing/A/program
?