Run script using system variable

1

I have a simple script in bash :

#!/bin/bash
echo "Hello world"

And he executed it on my console with a simple:

user@host: $ sh script.sh
Hello World 

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

user@host: $ SCRIPT
Hello World

How can I do it?

    
asked by Jorius 23.11.2016 в 02:28
source

2 answers

2

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/script.sh'

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
source
0

First this

You make the executable file

chmod +x script.sh

You add to the PATH of S.O

PATH=$PATH:/directorio/del/archivo
export PATH

Then you go to another folder and put

script.sh

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

    
answered by 23.11.2016 в 02:37