next up previous
Next: Accessing the Files and Up: Lab 2: Shell, Environment Previous: Changing PATH

A Simple Shell Script

Scripting languages are similar to batch files in DOS environment. A shell script is a sequence of UNIX commands in a text (ASCII) file. The following sequence of commands creates a script file named first with one UNIX command:

cd $\tilde{} $ /cs241/lab2
vi first
man -k shell $\vert$ sort -u $\vert$ more
(save and exit the file by pressing ESC :wq)

To execute it in bourne shell use:

sh first

For shell, first is not an executable program yet. To become one, the command

chmod a+x first must be executed. Now,

./first

executes the shell script as desired.

More complicated shell programs are discussed in lab3.



Instructional Support Group 2008-08-05