Individuals requiring a mastery of the command line interface to the
UNIX operating system. This includes system administrators,
programmers, and power users. This course is a follow-on to the
Korn Shell Programming introductory course.
Development of this course is ongoing and the content
and duration are subject to change.
- Interactive Use of the Shell
- Advanced I/O Redirection
- Using file descriptors other than 0, 1, and 2
- Closing a file descriptor when I/O is complete
- Capturing stderr from commands in a pipe
- Using I/O redirection with remote commands (such as with
ssh)
- Examples
- Command Line Parsing
- Detailed look at the order of evaluation
- Using the
builtin and command commands
- What is
eval and how is it used?
- Examples
- Using Aliases
- Aliases as shortcuts for commands
- Aliases as shortcuts for entire command lines
- Where do aliases appear in the parsing order?
- Using aliases in sourced scripts (ie. the
. command)
- Examples
- Command Line Editing
- Enabling
vi-mode
- Recalling previous command lines
- Editing using
vi commands
- Creating edit macros using
aliases
- Examples
- Programming Topics
- Command and variable substitution
- Old-style (obsolete) syntax
- New-style syntax
- Single and double quotes: When to use each type
- Examples
- Data types for variables using
typeset
- Performance aspects
- Functional aspects
- When to use
printf for formatting
- Suggestions for integrating typed variables with
read
- Examples
- Shell functions
- Definition: What is a shell function?
- Defining shell functions
- Using functions in scripts
- Building reusable libraries
- Examples
- Using
eval
- Examples of the need for
eval
- Issues related to quoting
- Suggestions for how to avoid complicated cases
- Examples
- Using autoload functions
- How to use FPATH and
typeset -f together
- When the FPATH is searched
- Recent changes in the shell regarding autoloaded functions
- Examples
- Using dot command
- What the dot command does
- How to build libraries for shell script use
- Examples
- Arrays
- What is an array?
- Syntax for creating and accessing arrays
- When should arrays be used?
- Limits in various implementations
- Associative arrays (string instead of numeric subscripts)
- Examples
- Compound variables
- What is a compound variable?
- The shell's built-in compound variables
- User-defined compound variables: why?
- Examples
- Testing files
- Differences between
test, [ ], and [[ ]]
- Testing the type of a file
- Testing the size of a file
- Testing for access to a file (read/write/execute)
- Examples
- Coprocesses
- What is a coprocess?
- When are coprocesses useful?
- Examples
- Program flow control
- Review of
if, while, for, and case
- The
until loop
- Details of using
select for interactive menus
- Examples
- Debugging programs
- Advanced uses of the
trap command
- How signals are caught using
trap
- The execution environment of trap handlers
- Practical use of trap handlers
- Examples
- Invocation and environment
- What steps does the shell take at startup?
- Is the environment cleansed in any way?
- Can shell scripts be setuid?
- Examples
- Performance evaluation and tuning
- Why performance matters in shell scripts
- Development of a general timing harness
- Examples
Upon completion of this course, the student will be able to
write and debug advanced Korn Shell scripts using the
following features and more:
-
Opening files for read, write, and read/write from within the shell,
-
Using all 20 forms of parameter expansion for precise control of
expressions,
-
Using associative arrays to increase performance in lookup-intensive
scripts,
-
Using formatted variables to produce specific output layouts,
-
Create coprocesses as a rudimentary form of parallel processing.
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.
Extensive use of UNIX commands and shell scripting. The student should
be thoroughly familiar with directories, file permissions, and using the
system editor (such as vi).
There is no review of basic features of the shell as covered in
the Korn Shell Programming introductory course, so students
must be moderately well-versed in shell scripting.