Course Description
In this three-day hands-on course students learn how to read, write, and debug complex Z shell scripts.
Course Objectives
Upon successful completion of this course, students will be able to:
- Read and understand Z shell scripts
- Debug Z shell scripts
- Customize and extend their user environment with Z shell scripts
- Create interactive menus with Z shell scripts
- Use all key language features of the Z shell: variables, arrays, branches, loops and functions
- Write Z shell scripts that perform complex file handling, string manipulations and mathematics
Course Benefits
Although it is a powerful scripting language, Z shell is a shell designed for interactive use. Students will increase their productivity by taking full advantage of the Z shell.
Who Should Attend
This course is valuable for system administrators, developers and other computer professionals involved with UNIX.
Prerequisite
To ensure your success, we recommend you first take either our Introduction To UNIX course or our Introduction To UNIX course, or have the equivalent knowledge. Familiarity with Web browsers, the
vi
editor, and UNIX command line interface is assumed.Method Of Instruction
Lecture, demonstrations, questions and answers, and numerous hands-on exercises.
Hands-on Exercises
Throughout this course, students perform a series of extensive hands-on exercises including:
- Creating loops and making decisions using
while
andfor
loops- Writing scripts to perform matematical calculations
- Using
eval
for dynamic commands- Handling errors with default values
- Breaking a large program into reusable modules using functions
- Manipulating multiple files
- Handling unexpected events with
trap
- Processing command line options
- Building an interactive menu interface using
case
constructs andread
Course Outline
Chapter 1: UNIX Processes and ShellsChapter 2: Variables
- What is a Process?
- What is a Shell?
- Process Structure
- The
ps
Utility- Background Commands (&)
- Killing Background Processes
- Redirecting the Standard Error
- Specifying the Script's Interpreter
- Environment Variables
- Sub-shells
Chapter 3: The Login Process
- Shell Variables
- The
read
Command- The
export
Command- The Shell Environment
- Parameter Expansion
- Command Substitution
Chapter 4: Conditional Statements
- The Login Process
- The System Profile Script
- Customizing your environment with
.profile
Chapter 5: Loops
- The Exit Status of Commands
- Command Line Examples
- The
test
Command- The
if-then-else
Construct- The
elif
Construct- The
case
ConstructChapter 6: Special Variables
- For Loop
- While Loop
- break and continue
- Reading Lines From Files
- Using Arrays with Loops
Chapter 7: Quoting Mechanisms
- $$ - PID of Shell
- Command-Line Arguments
- $# - Number of Arguments
- $* - All Arguments
- The
shift
Command- The
set
Command- Getting Options
Chapter 8: Functions
- Single vs. Double Quotes
- Literals
- Regular Expressions
- Ignoring Leading Tabs
Chapter 9: Advanced Programming
- Shell Functions
- Passing Arguments to Functions
- Setting and unsetting parameters
- Defining global and local variables
- Specifying default values and error conditions
- Returning Values from Functions
- Function Declarations
Chapter 10: Debugging Techniques
- Shell Arithmetic
- The
select
Statement- Terminal Independence in Scripts
- The
eval
Command
- Using
echo
- Using Standard Error
- Script Tracing
- Options for Debugging
- Conditional Debugging