Find Courses Here
Bash Shell Programming Print E-mail
Course Length - 3 Days
 
Course Description

In this three-day hands-on course students learn how to read, write, and debug complex Bash shell scripts.

 
  
You Will Learn How To

Upon successful completion of this course, students will be able to: 

  • Read and understand Bash shell scripts
  • Debug Bash shell scripts
  • Customize and extend their user environment with Bash shell scripts
  • Create interactive menus with Bash shell scripts
  • Use all key language features of the Bash shell: variables, arrays, branches, loops and functions
  • Write Bash shell scripts that perform complex file handling, string manipulations and mathematics
 
  
Course Benefits

Bash is the default shell for Linux. Students will increase their productivity by taking full advantage of the Bash shell.

 
  
Course Prerequisites

To ensure your success, we recommend you first take either our Introduction To UNIX course or our Introduction To Linux course, or have the equivalent knowledge. Familiarity with Web browsers, the vi editor, and Linux command line interface is assumed.

 
  

Who Should Attend?

This course is valuable for system administrators, developers and other computer professionals involved with Linux.

 
  
Hands-On Exercises:

Throughout this course, students perform a series of extensive hands-on exercises, including: 

  • Creating loops and making decisions using while and for 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 and read
  • Building a colorful and sophisticated menu interface using dialog
  
Course Outline:  

UNIX Processes and Shells

 
  • 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
 
Variables 
  • Shell Variables
  • The read Command
  • The export Command
  • The Shell Environment
  • Parameter Expansion
  • Command Substitution
 
The Login Process 
  • The Login Process
  • The System Profile Script
  • Customizing your environment with .bash_profile
 
Conditional Statements 
  • The Exit Status of Commands
  • Command Line Examples
  • The test Command
  • The if-then-else Construct
  • The elif Construct
  • The case Construct
 
Loops 
  • For Loop
  • While Loop
  • break and continue
  • Reading Lines From Files
  • Using Arrays with Loops
 
Special Variables 
  • $$ - PID of Shell
  • Command-Line Arguments
  • $# - Number of Arguments
  • $* - All Arguments
  • The shift Command
  • The set Command
  • Getting Options
 
Quoting Mechanisms 
  • Single vs. Double Quotes
  • Literals
  • Regular Expressions
  • Ignoring Leading Tabs
 
Functions 
  • 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
 
Advanced Programming 
  • Shell Arithmetic
  • The select Statement
  • Terminal Independence in Scripts
  • The eval Command
  • Using dialog
 
Debugging Techniques 
  • Using echo
  • Using Standard Error
  • Script Tracing
  • Options for Debugging
  • Conditional Debugging