Библиотека сайта rus-linux.net
Having written the script, you can invoke it by
bash scriptname. (Not
recommended is using
since this effectively disables reading from
within the script.) Much more convenient is to make
the script itself directly executable with a chmod.
chmod 555 scriptname(gives everyone read/execute permission) 
chmod +rx scriptname(gives everyone read/execute permission)
chmod u+rx scriptname(gives only the script owner read/execute permission)
Having made the script executable, you may now test it by
If it begins with a "sha-bang" line, invoking the
script calls the correct command interpreter to run it.
As a final step, after testing and debugging,
you would likely want to move it to
root, of course), to make the script
available to yourself and all other users as a systemwide
executable. The script could then be invoked by simply typing
scriptname [ENTER] from the
Caution: invoking a Bash
A script needs read, as well as execute permission for it to run, since the shell needs to be able to read it.
Why not simply invoke the script with