UNIX KORN SHELL PROGRAMMING

 

 

 

 

General:

 

This course provides an understanding of the command and programming language capabilities of the UNIX System V standard Korn Shell from a programming perspective. It also explains commands particularly useful in conjunction with Shell programs, as well as all of the programming constructs available within the both the Bourne and Korn Shells.

 

 

 

Objectives:

 

Upon successful completion of this course, the student will be able to:

 

         Describe the purpose and functions of the Shell Interpreter.

         Use UNIX System commands useful for Shell programming.

         Create and execute Shell programs.

         Use additional forms of input and output redirection in conjunction with Shell programs.

         Establish and use parameters and variables within Shell programs.

         Describe and use special Shell variables.

         Use the Shell quoting mechanisms to escape the meaning of special characters.

         Use all of the Shell control structures.

         Trace, debug, and document Shell programs.

 

 

 

Audience:

 

UNIX users who require a general knowledge of Shell Programming.

 

 

 

Prerequisites:

 

Introduction to UNIX course or equivalent experience, and experience in programming in any high level programming language.

 

 

 

Duration:

 

Three (3) days. Class consists of classroom lecture and lab sessions.

 


 

SHELL PROGRAMMING

COURSE OUTLINE

 

 


I.           INTRODUCTION TO THE SHELL

 

A.   What is the Shell Interpreter?

B.    Functions of the Shell Interpreter

C.    What is a Shell Procedure?

D.    Creating Shell Programs

E.     Implicit and Explicit Execution

 

 

II.         COMMAND LINES & IF CONSTRUCT

 

A.   Useful Shell Commands

B.    Command Lines

1.     Sequential

2.     Grouped

3.     Conditional Operators

C.    The if Construct

D.    The if-else Construct

E.     The if-elif Construct

 

 

III.       PARAMETERS & VARIABLES

 

A.   What is a Variable?

B.    Assigning to Variables

C.    The read Statement

D.    Quoting

1.     Special Characters

2.     Backslash

3.     Single Quoting

4.     Double Quoting

E.     The while Loop

F.     Special Variables

G.    export and readonly

H.    Positional Parameters

 


IV.       TEST & CASE STATEMENTS

 

A.   test Statement Features

1.     File Status

2.     String Comparison

3.     Numeric Comparison

B.    The case Statement

 

 

V.         INPUT/OUTPUT CONSIDERATIONS

 

A.   Command Substitution

B.    Redirection of Errors Messages

C.    The Here Document

D.    The for Loop

 

 

VI.       DEBUGGING & DOCUMENTING

 

A.   Keyword Parameters

B.    Tracing Shell Procedures

C.    Handling External Events

D.    Comments as Documentation