Module 13: Shell Scripts in UNIX - E-Courses
Module 13: Shell Scripts in UNIX - E-Courses
Module 13: Shell Scripts in UNIX - E-Courses
Create successful ePaper yourself
Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.
Operat<strong>in</strong>g Systems Prof. P. C. P. Bhat<br />
Indian Institute of Science Bangalore<br />
Operat<strong>in</strong>g Systems/<strong>Shell</strong> <strong>Scripts</strong> <strong>in</strong> <strong>UNIX</strong> Lecture Notes<br />
Figure <strong>13</strong>.1: A Unix system shell.<br />
<strong>13</strong>.1.1 The <strong>Shell</strong> Families<br />
One of the oldest shells is the Bourne shell. In most Unix mach<strong>in</strong>es it is available either<br />
<strong>in</strong> its orig<strong>in</strong>al form or as BASH which expands to Bourne Aga<strong>in</strong> <strong>Shell</strong>. An improvement<br />
over the Bourne shell was the Korn shell. To properly enmesh with c language<br />
programm<strong>in</strong>g environment, a new family of shells came along. The first <strong>in</strong> this family is<br />
csh, the c shell. csh has its more recent version as tchs.<br />
The Bourne shell is the primary shell. It has all the primary capabilities. The subsequent<br />
shells provided some extensions and some conveniences. Notwithstand<strong>in</strong>g the<br />
differences, all shells follow a four-step operational pattern and that is:<br />
1. Read a command l<strong>in</strong>e.<br />
2. Parse and <strong>in</strong>terpret it.<br />
3. Invoke the execution of the command l<strong>in</strong>e.<br />
4. Go to step 1.<br />
When there are no more command l<strong>in</strong>es, the shell simply awaits one. As a programm<strong>in</strong>g<br />
environment, a shell programm<strong>in</strong>g language allows a user to write a program, often<br />
called a shell script. Once a script is presented to a shell, it goes back to its four-step<br />
operational pattern and takes commands from the script (exactly as it would have done<br />
from the term<strong>in</strong>al). So what is the advantage of the script over the term<strong>in</strong>al usage? The<br />
advantages manifest <strong>in</strong> the form of automation. One does not have to repeatedly type the<br />
PCP Bhatt/IISc, Bangalore M<strong>13</strong>/V1/June 04/2