EEC Logo


Korn Shell Programming

Duration: 3 days

Audience

Individuals requiring a mastery of the command line interface to the UNIX operating system. This includes system administrators, programmers, and developers. Shell scripting is the simplest way to automate tasks on UNIX systems and this course provides excellent coverage of the shell and its associated facilities. The Advanced Korn Shell Programming course follows this one and provides an in-depth look at shell features that go beyond ordinary use.

Course Contents

  1. Review of Useful Shell Commands
    1. Tools for Text Files (head and tail, cut, grep)
    2. File Management Commands (find, chmod, cp/mv)
    3. Overview of Other Scripting Languages (awk, sed, perl)
  2. Shell Basics
    1. Using Redirection and Pipes
    2. Wildcards (including the extended wildcards)
    3. Command and Variable Substitution
    4. Creating and Using Shell Scripts
    5. Single and Double Quotes
    6. Command Line Parsing
    7. Login and Shell Startup Scripts
  3. Process Lifecycle
    1. Terminology (process, parent/child, and more)
    2. Monitoring Commands (ps, top)
    3. How Shell Scripts are Executed
    4. Using nohup and nice
    5. Background Processing
    6. Signals and Killing Processes
  4. Shell Scripting, Part 1: Basics
    1. Why Shell Programming?
    2. Steps to Creating a Script
    3. Menu Building Example Using select
    4. Commenting Your Shell Scripts
    5. Working with Variables
    6. Parameter Substitution Modifiers
    7. Introduction to Indexed Arrays
    8. Proper Use of Error Messages
    9. Performing Arithmetic in the Shell With (( )) and let
    10. Using expr for String Matching (deprecated)
    11. Interactive Shell Scripts Using read
  5. Shell Scripting, Part 2: Flow Control
    1. Control Flow: if-then-else
    2. Test Operations (test, [ ], and [[ ]])
    3. Control Flow: for Loops
    4. Control Flow: while Loops
    5. Changing the Script Parameters
    6. Changing Loop Flow (break and continue)
    7. Multi-choice case Statements
    8. Exiting a Shell Script
    9. Using select to Build a Menu
  6. Shell Scripting, Part 3: User Interaction
    1. Using getopts For Handling Options
    2. Temporary Files
    3. The trap Command
    4. Debugging Options in the Korn Shell
  7. Shell Scripting, Part 4: Efficiency
    1. Subshells and IO Redirection
    2. Conditional Execution
    3. Floating Point Arithmetic
    4. Example of Using Coprocesses
    5. HERE Documents
    6. Introduction to Shell Functions
  8. Appendix: Using ksh
    1. Korn Shell Startup Sequence (/etc/profile, .profile, $ENV)
    2. Command Line Editing
    3. Using the Command History and Command Alias Facilities
    4. Korn Shell Job Control
    5. The Shell Environment

Course Objectives

Upon completion of this course, the student will be able to write 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

Familiarity with UNIX commands, directory structure, and the text editor is required; this course includes a short review of some basics, but proficiency with the system editor is required.

Programming skills are not required, but are helpful.