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
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.