Course 593:
Shell Programming

(3 days)

 

Course Description

This intense three-day course provides attendees with a thorough understanding of shell programming in ksh-93 shell on Linux systems. At the end of the class, each student will know when and how to expertly use ksh-93 to automate repetitive tasks. Attendees will also learn the limitations and advantages of using a shell scripting language.

Each student will receive a CD-ROM with all class examples and documented real-world programs. This class emphasizes learning by doing!

Learning Objectives

  • Professional script setup
  • Correctly using command line options and parameters
  • Techniques of debugging shell scripts
  • How to use conditional and looping statements
  • Advanced manipulation of shell variables
  • Complete understanding of shell I/O
  • How to build effective, reusable shell functions
  • How to create function libraries

Who Should Attend

System administrators, Web administrators, and programmers.

Prerequisites

This course is delivered on a Linux platform. A basic understanding of the command line interface and a Linux editor (vi, emacs, gedit, nano) enhances the learning experience.


Course Outline

Getting Started

  • Command Line vs. Shell Script?
  • Review of Command Line
  • Command Syntax
  • Professional Shell Scripting Introduction
  • echo and print Commands

Simple Variables

  • Shell Variable Definition
  • read Command
  • export and typset Command
  • Survey of Predefined Shell Variables
  • More on Script Setup

Substitution Mechanisms

  • Single vs. Double Quotes
  • Variable Substitution
  • Command Substitution
  • Process Substitution

Shell I/O

  • Input Redirection
  • Output Redirection
  • Here Documents
  • Advanced File Techniques
  • Using Pipes in Shell Scripts

Debugging Techniques

  • Using print and Standard Error
  • Options for Debugging
  • Script Tracing
  • Conditional Debugging

Conditional Statements

  • The Exit Status of Commands
  • test and [[ ]] and [ ] Commands
  • if-then-else Construct
  • elif Construct
  • case Statements
  • I/O Redirection on Conditional Statements

Loops

  • for Loop
  • arithmetic for Loop
  • while Loop
  • break and continue Commands
  • I/O Redirection on Loops
  • Using Arrays with Loops

Command Line Options and Parameters

  • Command-Line Parameters
  • The shift Command
  • Processing Command Line Options
  • A Trick with Set

Functions

  • Shell Functions
  • Passing Arguments to Functions
  • Returning Values from Functions
  • Local Variables
  • Using nameref
  • Function Libraries

Advanced Programming

  • Shell Arithmetic
  • Shell Variable Manipulation
  • select Statement
  • Terminal Independence in Scripts
  • eval Command
  • Job Control
  • Using ( ) and { ;}
  • Discipline Functions

Shell IPC

  • Co-Processes
  • The print and read Commands
  • Signals
  • The trap Command
  • Named Pipes
  • The wait Command
  • Networking in the Shell

Some Useful Commands

  • sed for Shell Scripting
  • Awk for Scripting
  • Using xargs
  • Using Zenity

Some Wicked, Cool Shell Scripts

  • A Collection of Shell Scripts to Do Some Fun (and Useful) Things

Please Contact Your ROI Representative to Discuss Course Tailoring!