You are here:
Shell Scripting

This hands-on course provides the skills needed to create and maintain shell programs used in managing and enhancing the operation of user environments for UNIX systems.

 
Who Should Attend
Computer professionals who want to sharpen their skills using the UNIX shell.
 
Prerequisites

UNIX For Users or three months experience using UNIX commands and utilities. Some programming experience is helpful.

 
Benefits of Attending this Class
Upon completion of this course, students should be able to:
  • Utilize I/O redirection and pipelines
  • Use metacharacters for pattern matching
  • Set up and modify user environments
  • Create and execute shell scripts
  • Define and use variables
  • Write programs using flow-control constructs
  • Use the test command to detect conditions
  • Set shell traps to catch signals
  • Export variables to global shell environments
  • Use debugging techniques to aid program correctness
  • Relate common features and differences between Bourne, Korn and other shells
 
Course Contents

The Shell as a Process

  • Objectives
  • Why Bother with Shell Programming?
  • Kernel, Utilities, and Shell
  • The Shell
  • Which Shell?
  • Shell History
  • How Does Your System Know What Shell to Start for You?
  • Shell Startup
  • Traditional Terminal Login Sequence
  • Processes Tables
  • Shell Questions and Answers
  • Excursion: UNIX System Calls
  • Starting a Process in C
  • Running a Program
  • Who Opens the Files?
  • Redirecting I/O
  • Shell Process
  • Foreground/Background Processing
  • Additional Shell Responsibilities
  • Special Shell Features
  • Examples of Features of the Shell
  • Summary
  • Lab 1

Creating a Command File

  • Objectives
  • Command File
  • File Creation
  • File Naming Conventions
  • Revisiting Unix File Permissions
  • Three Ways to Execute Shell Files
  • Other Ways to Execute Shell Files
  • PATH Variable
  • Creating an Executable Shell File
  • Shell Must Locate Executable Files
  • Remembering Old Friends
  • Summary
  • Lab 2

Error Debugging

  • Objectives
  • Termination of a Shell Program
  • For Debugging
  • exit Status
  • Execution Flags
  • Invocation Flags
  • Error Handling
  • Summary
  • Lab 3

Redirection and Pipelines

  • Objectives
  • Redirection (>, >>, <)
  • File Descriptors
  • Standard Input, Standard Output, and Standard Error
  • Input/Output Redirection
  • Input/Output Redirection Examples
  • Pipelines: Connecting Command Processes
  • Pipeline Examples
  • Helpful Hints Using Pipelines
  • Differences Between Pipelines and Redirection
  • here Document
  • here Document Examples
  • here Document Examples - 2
  • here Document Examples - 3
  • Summary
  • Lab 4

Variables

  • Objectives
  • Definition of a Shell Variable
  • Assigning Variables Example
  • Assigning Variables (read)
  • Assigning Variable on the Command Line
  • The Values of Shell Variables
  • Assigning Variables with Quotes
  • Variable Assignment
  • Predefined Shell Variable
  • Predefined Shell Variables (Default Values)
  • .bashrc File
  • Predefined Shell Variable Examples
  • Example of Changing .bashrc
  • Shell Defined Variables (readonly)
  • Summary
  • Lab 5

Parameters

  • Objectives
  • Positional and Special Parameters to the Shell
  • Shifting Positional Parameters
  • Positional Parameters to the Shell
  • Parameter Substitution
  • Parameter Substitution Exercises
  • Parameter Substitution Summary
  • Summary
  • Lab 6

Pattern Matching and expr

  • Objectives
  • Shell File Name Substitution Characters
  • Shell Pattern Matching Examples
  • Quoting
  • Metacharacters
  • Regular Expression Special Characters
  • Utility Regular Expressions
  • Differences between the Shell regular expressions and regular
  • expressions used
  • within utilities
  • Evaluate an Expression
  • Notes on expr
  • expr examples
  • Summary
  • Lab 7

More on Commands

  • Objectives
  • Command Line Evaluation
  • Command Substitution Examples
  • Shell Script
  • Command Delimiter Examples
  • Short-Circuit Operators
  • Braces and Parentheses
  • Summary
  • Lab 8

Exit/Test

  • Objectives
  • exit Status
  • The test Command
  • Types of Tests
  • Tests on Numerical Values
  • Examples Testing Numerical Values
  • Tests on Files Types
  • Examples Testing File Types
  • Tests on Character Strings
  • Examples Testing Character Strings
  • Comparison of Character Strings and Numeric Strings
  • Logical AND Operator
  • Logical OR Operator
  • Summary

Conditional Constructs

  • Objectives
  • Programming Concepts
  • Advantages/Disadvantages of Shell Scripts
  • Flow Control - if
  • Flow Control - if Examples
  • Flow Control - elif
  • Flow Control - elif Examples
  • Flow Control - case
  • Flow Control - case Example
  • Patterns in the case Structure
  • case Examples
  • Summary
  • Lab 9 and 10

Looping Constructs

  • Objectives
  • Flow Control: for in
  • Flow Control: for in Examples
  • Flow Control: while
  • Flow Control: while Examples
  • Comparison Between for and while
  • for, while Examples
  • Flow Control: until
  • until Examples
  • Programming Notes
  • Summary
  • Lab 11

Shell Functions

  • Objectives
  • Shell Functions
  • Defining a Function
  • Examples
  • Lab 12

Exporting

  • Objectives
  • Variables in Processes
  • Exporting Variables
  • Exporting Notes
  • Exporting
  • Actions on Shell Variables
  • Summary
  • Lab 13

Interactive Use

  • Objectives
  • Bourne-Again Shell
  • Command Line Editing
  • Command History
  • Using Previous Commands
  • Built-In Integer Arithmetic
  • Parameter Substitution
  • alias Command
  • Job Control
  • Starting and Stopping Jobs
  • cd Command
  • Tilde Substitution
  • Command Substitution
  • Shell Variables
  • Quoting
  • Quoting Examples
  • Exported Variables
  • Select Command
  • Summary
  • Lab 14

Signals and Traps

  • Objectives
  • Signals
  • Traps
  • trap Example
  • Application of Signals
  • Summary
  • Lab 15

Built-In Commands

  • Objectives
  • Built-In Commands
  • Advantages/Disadvantages of Built-In Commands
  • Built-In Commands Summary
  • Lab 16

Bourne-Again Shell

  • Objectives
  • Bourne-Again Shell
  • Built-In Integer Arithmetic
  • Parameter Substitution
  • Command Substitution
  • Shell Variables
  • Quoting
  • Quoting Examples
  • Exported Variables
  • Select Command
  • Summary
  • Lab 17

Unix Power Tools

  • Objectives
  • find
  • diff
  • ed
  • dc
  • join
  • comm
  • sed
  • tail
  • Summary
  • Lab 18
 

 
 
Disclaimer: HP-UX, Tru64 Unix, OpenVMS and are registered trademarks of the Hewlett Packard Corporation. Solaris and Java are registered trademarks of Sun Corporation. AIX is a registered trademark of IBM. Oracle is a registered trademark of Oracle Corporation.