All tricks in this blog are only for educational purpose. Learn these tricks only for your knowledge. Please donot try these to harm any one. We will not take any responsibility in any case. All softwares and tools on this site are here for private purposes only and If you want to use a software for business purpose, please purchase it. I do not host many of these tools. I Post links that I have found from numerous Search engines. I will not be responsible for any of harm you will do by using these tools.


Thursday, September 23, 2010

Unix Shell Scripting Tutorial

Time is precious. It is non-sense-ical to waste time typing a frequently used sequence of commands at a command prompt, more especially if they are abnormally long or complex. Scripting is a way 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 tutorialyou should have a good idea of the kinds of scripting languages avail-able for Unix and how to apply them to your problems. 2. Environment In order to peruse this tutorial with ease it is probably necessary to know a little bit about how Unix works, if you are new to Unix you should read the documentation.

Configuring A Unix Working Environment [../unixenvars/unixenvars home.html], if you are not new to Unix you should browse it to check that you know everything it discusses.Unix contains many wonderful and strange commands that can be very useful in the world of scripting, the more of the tools you know and the better you know them, the more use you will find for them in your scripting. Most of the Unix commands and many of the built in commands have man pages, man pages contain the usage instructions and other stuff pertaining to the parent tool.They are not always very clear and may require reading several times. In order to access a man page in Unix the following command sequence is applied: man command If a man page exists for the command specified the internal viewer will be invoked and you will be able to read about the various options and usage instructions etc. 3. Shell Scripting 3.1. 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(C SHell) 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 specificshell 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.

Download Unix Shell Scripting Tutorial.


Post a Comment