2.1. Invoking the script

Having written the script, you can invoke it by sh scriptname, or alternately bash scriptname. (Not recommended is using sh <scriptname, since this effectively disables reading from input within the script.) Much more convenient is to make the script itself directly executable by

Either:

chmod 755 scriptname (gives everyone execute permission)

or

chmod +x scriptname (gives everyone execute permission)

chmod u+x scriptname (gives only the script owner execute permission)

In this case, you could try calling the script by ./scriptname.

As a final step, after testing and debugging, you would likely want to move it to /usr/local/bin (as root, of course), to make the script available to yourself and all other users as a system-wide executable. The script could then be invoked by simply typing scriptname [return] from the command line.