EEC Logo


Advanced Korn Shell Programming

Duration: 4 days (projected)

Audience

Individuals requiring a mastery of the command line interface to the UNIX operating system. This includes system administrators, programmers, and power users. This course is a follow-on to the Korn Shell Programming introductory course.

Course Contents

Development of this course is ongoing and the content and duration are subject to change.

  1. Advanced I/O Redirection
    1. Using file descriptors other than 0, 1, and 2
    2. Closing a file descriptor when I/O is complete
    3. Capturing stderr from commands in a pipe
    4. Using I/O redirection with remote commands (such as with ssh)
  2. Command and variable substitution
    1. Old-style (obsolete) syntax
    2. New-style syntax
    3. Single and double quotes: When to use each type
  3. Data types for variables using typeset
    1. Performance aspects
    2. Functional aspects
    3. When to use printf for formatting
    4. Suggestions for integrating typed variables with read
  4. Arrays
    1. What is an array?
    2. Syntax for creating and accessing arrays
    3. When should arrays be used?
    4. Limits in various implementations
    5. Associative arrays (string instead of numeric subscripts)
  5. Shell functions: Basics
    1. Definition: What is a shell function?
    2. Defining shell functions
    3. Using functions in scripts
    4. Building reusable libraries
  6. Shell functions: Advanced
    1. What are autoload functions?
    2. How to use PATH, FPATH, and typeset -f
    3. When is FPATH is searched?
    4. Recent changes in the shell regarding autoloaded functions
  7. Using eval
    1. Examples of the need for eval
    2. Issues related to quoting
    3. Suggestions for how to avoid complicated cases
  8. Program flow control
    1. Review of if, while, for, and case
    2. The until loop
    3. Details of using select for interactive menus
  9. Compound variables
    1. What is a compound variable?
    2. The shell's built-in compound variables
    3. User-defined compound variables: why?
  10. Coprocesses
    1. What is a coprocess?
    2. When are coprocesses useful?
  11. Debugging programs
    1. Using the shell's -e, -x, and -v options
    2. Using the ERR and DEBUG signals with the trap command
    3. Can you use kshdb?
  12. Performance evaluation and tuning
    1. Why performance matters in shell scripts
    2. Development of a general timing harness

Course Objectives

Upon completion of this course, the student will be able to write and debug advanced Korn Shell scripts using the following features and more:

Instructional Technique

Students are invited to bring their current ideas and questions to the classroom for discussion. Case studies, lecture, group problem solving, and online laboratories will be used. Students will be encouraged to enhance their skills utilizing the techniques presented through classroom problem solving and controlled online workshops.

Prerequisites

Extensive use of UNIX commands and shell scripting. The student should be thoroughly familiar with directories, file permissions, and using the system editor (such as vi). There is no review of basic features of the shell as covered in the Korn Shell Programming introductory course, so students must be moderately well-versed in shell scripting.