Run script using system variable


I have a simple script in bash :

echo "Hello world"

And he executed it on my console with a simple:

[email protected]: $ sh
Hello World 

That said, I would like to execute the above ( sh ) by means of a "system and / or global" variable that I can configure (how it is done with npm modules)

[email protected]: $ SCRIPT
Hello World

How can I do it?

asked by Jorius 23.11.2016 в 02:28

2 answers


Using the text editor you want (in my case, gedit) go to the terminal and copy the following

$ sudo gedit ~/.bashrc

Being inside that file .bashrc copies the following in the last line

alias SCRIPT='sh /directorio/donde/este/el/script/'

Then you restart the terminal, and when you execute $ SCRIPT in the terminal you should perform the action that you put.

answered by 23.11.2016 / 02:47

First this

You make the executable file

chmod +x

You add to the PATH of S.O

export PATH

Then you go to another folder and put

If you want to put them without .sh just change the name to the file.

answered by 23.11.2016 в 02:37