A shell script is just an ASCII file (52.9) containing a saved sequence of commands.
If you were to store a list of commands in a file for one-time use, you could execute it by typing:
%sh
mycommands
where mycommands
is the name of the file containing the
list of commands. This would tell the shell to treat the
file as a list of commands to be executed.
But there's a better way to tell the shell to execute the contents of a file, and that is to make the file executable with the chmod (22.7) command:
%chmod +x
mycommands
Then, all you have to do to execute the script is type its name. (To make it even easier to use, you should store it in a personal bin directory and add the bin to your search path .) (8.7)
Of course, in either case, all of the lines in the file need to be meaningful to the shell! If you accidentally made a letter to your mother executable, and tried to run it as a shell script, you'd get error messages like this, containing the first word of each line in the letter:
letter: Dear: not found
The shell would try to interpret that word as a command, and report back that it doesn't know any command by that name.
Also, to really make good use of shell scripts, you need to understand how to pass arguments to a script (44.15) and how to use some simple programming constructs (1.5).
-