EEC Logo

Advanced Bash Shell Programming

Duration: 3 days


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 Bash Shell Programming introductory course.

Course Contents

Development of this course is ongoing and the content and duration are subject to change.

  1. Bash Shell Basics

    1. IO Redirection

    2. Using Pipes

    3. Wildcards for Filenames

    4. Command Substitution

    5. Variable Substitution

    6. Single and Double Quotes

    7. Examples of Quoting

    8. Command Parsing Order

    9. Special Shell Scripts

    10. Things You Should Already Know

  2. Advanced IO Redirection

    1. File Descriptors Beyond 0, 1, and 2

    2. Simultaneously Reading from Multiple Sources

    3. Closing a File Descriptor

    4. Capturing stderr or Exit Code from a Pipe Command

    5. Special Filenames Recognized with IO Redirection

    6. Process Substitution

    7. Using IO Redirection with Builtin Shell Commands

  3. Command Substitution

    1. The Old Way: ``

    2. The New Way: $()

    3. Using Quotes with Command Substitution

  4. Data Types

    1. The declare Command (a.k.a. typeset)

    2. When to Use declare

    3. Version-dependent Features

  5. Indexed Arrays

    1. What are Indexed Arrays?

    2. Static Creation

    3. Dynamic Creation

  6. Shell Functions

    1. What is a Shell Function?

    2. Options for Defining Functions

    3. Function Invocation

    4. Examples of Using Functions

    5. Building Reusable Function Libraries

    6. Examples of Function Libraries

  7. Associative Arrays

    1. What are Associative Arrays?

    2. Static Creation

    3. Dynamic Creation

    4. Examples of Using Associative Arrays

    5. Performance Characteristics

  8. Advanced Shell Functions

    1. What is Function Autoloading?

    2. Configuration Options

    3. IO Redirection in a Function Definition

  9. The eval Command

    1. What is eval?

    2. Examples of What eval Can Do

    3. Examples of How Complicated eval Can Become!

    4. Techniques for Avoiding Complicated Cases

  10. Debugging Scripts

    1. Available Debugging Tools

    2. Using Shell Options for Debugging

    3. Discipline Functions

    4. Background Information for the ERR Trap

    5. Background Information for the DEBUG Trap

    6. Using the logger Command

    7. Common Debugging Approaches

    8. What is bashdb?

    9. Other Useful Shell Variables

  11. Examples and Wrapup

    1. Examples (from student requests)

    2. Processing Log Files

    3. Processing XML Files

    4. Processing INI Files

    5. Finishing Up

    6. Closing Words

Course Objectives

Upon completion of this course, the student will be able to write and debug advanced Bash Shell scripts using the following features and more:

This course does not cover the interactive features of the Bash shell.

Instructional Technique

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.


Familiarity with UNIX commands and shell scripting. There is no review of basic features of the shell as covered in the Bash Shell Programming scripting course, so students should be moderately well-versed in simple shell scripting, including the creation of scripts from scratch, and thoroughly familiar with directories, file permissions, and using the system editor (such as vi).

Programming skills should be fairly well-developed before taking this course; students without experience will likely find the pace to be too fast.