How do I make a new command to run a script, for example if I type runme
(from any dir) it will run /run/me/script.sh
?
Seems simple but I can find anywhere that explains how to do this :/
How do I make a new command to run a script, for example if I type runme
(from any dir) it will run /run/me/script.sh
?
Seems simple but I can find anywhere that explains how to do this :/
simply add /run/me to your PATH, any script put there could be simply run from any directory
how to PATH from troubleshooters.com
To add directory /data/myscripts to the beginning of the $PATH environment variable, use the following:
To add that directory to the end of the path, use the following command:
finally
to have it everywhere, all the times, for your user only, add these in place the lines in that user's .bash_profile file
all users except root: add to /etc/profile
for root: only possible by root's .bash_profile
my idea for the sake of laziness (not your case of running 'every' script though): add a symbolic link from a single script there to your /home/usr/loca/bin
Two possiblities:
alias runme='/run/me/script.sh' at the bash command prompt. This works for this session only. Put this line in ~/.bashrc if you want this change to be persistent.
rename script.sh to runme and add /run/me to the PATH
http://nixcraft.com/shell-scripting/4490-how-can-i-set-path-bash-shell.html#post7234
P.S.: Make sure script.sh has executable rights (chmod +x script.sh)