Unix Shell Scripting Tutorial

Shell Scripting 3.1. Shell Scripting Introduction Unix uses shells to accept commands given … to be mentioned in this short tutorial, you should read the man page for your shell to …

Contents: Environment, Shell Scripting, Shell Scripting Introduction, Shell Scripting Basics, Command Redirection and Pipelines, Variables, Control Constructs, Functions.
Time is precious. It is non-sense-icaltowastetime typinga frequently used sequence of commands at a command prompt, more especially if they are abnormally long or complex. Scripting is away by which one can alleviate this necessity by automating these command sequences in order to make ones life at the shell easier and more productive. Scripting is all about making the computer, the tool , do the work. Hopefully by the end of this tutorial you should have a good idea of the kinds of scripting languages available for Unix and how to apply them to your problems. Shell Scripting Introduction. Unix uses shells to accept commands given by the user, there are quite a few different shells available. The most commonly used shells are SH(Bourne SHell) CSH(CSHell) and KSH(Korn SHell), most of the other shells you encounter will be variants of these shells and will share the same syntax, KSH is based on SH and so is BASH(Bourne again shell). TCSH(Extended CSHell) is based on CSH. The various shells all have built in functions which allow for the creation of shell scripts, that is, the stringing together of shell commands and constructs to automate what can be automated in order to make life easier for the user. With all these different shells available, what shell should we script in? That is debatable. For the purpose of this tutorial we will be using SH because it is practically guaranteed to be available on most Unix systems you will encounter or be supported by the SH basedshells. Your default shell may not be SH. Fortunately we do not have to be using a specific shell in order to exploit its features because we can specify the shell we want to interpret our shell script within the script itself by including the following in the first line. #!/path/to/shell Usually anything following (#) is interpreted as a comment and ignored but if it occurs on the first line witha (!) following it is treated as being special and the filename following the (!) is considered to point to the location of the shell that should interpret the script. When a script is “executed”it is being interpreted by an invocation of the shell that is running it. Hence the shell is said to be run- ningnon-interactively, when the shell is used “normally”it is said to be running interactively. Note. There are many variations on the basic commands and extra information which is too specific to be mentioned in this short tutorial, you should read the man page for your shell to geta more comprehensive idea of the options available to you. This tutorial will concentrate on highlighting the…

Source: http://supportweb.cs.bham.ac.uk/

Download Unix Shell Scripting Tutorial

Leave a Reply