You are on page 1of 3

Shell Programming with BASH

Table of Contents
Introduction............................................................................................ 5 I/O Redirection Examples................................................................47
What this Course is About................................................................. 6 Exercises.......................................................................................... 48
What is the shell?............................................................................... 7 The Here Document Syntax.............................................................49
The History of the Shell.....................................................................9 Using Pipelines to Combine Commands......................................... 50
Bash Shell Notable Features............................................................ 10 Subsequent Command Execution.................................................... 52
Shell Basics...........................................................................................11 Process Grouping for Redirection....................................................53
Interactive Shell Usage.................................................................... 12 Exercises.......................................................................................... 54
Files & Directories..........................................................................13 Process Management Basics.................................................................55
Filenames, Wildcards, and Pathname Expansion............................ 14 Characteristics of Processes.............................................................56
Exercises.......................................................................................... 17 Managing Processes.........................................................................58
Common Shell Utilities/Commands.....................................................18 Job Priorities.................................................................................... 60
Cat.................................................................................................... 19 Exercises.......................................................................................... 62
tr....................................................................................................... 20 Shell Special Characters....................................................................... 63
Grep..................................................................................................23 Special Metacharacters.................................................................... 64
Find.................................................................................................. 29 Control Keys.................................................................................... 66
Sort...................................................................................................31 Shell Help.........................................................................................68
Cut....................................................................................................32 Shell Command Line Editing...........................................................69
Head & Tail......................................................................................33 Tab Completion............................................................................... 71
Sed....................................................................................................34 History Expansion............................................................................73
Awk..................................................................................................37 Exercises.......................................................................................... 75
Exercises.......................................................................................... 39 Customizing the BASH Environment.................................................. 76
Handling Input/Output..........................................................................41 The User Environment.....................................................................77
I/O Channels.................................................................................... 42 Shell Aliases.....................................................................................79
I/O Redirection Operators................................................................44 Shell Options....................................................................................82

Page 2 of 169
Shell Programming with BASH

Shell Settings Descriptions.............................................................. 83 The Test Statement........................................................................ 127


Shell Variables................................................................................. 86 Integer Comparison Tests.............................................................. 128
Shell Built In Variables....................................................................88 String Comparison Tests................................................................129
Other Variables................................................................................ 94 File Tests........................................................................................131
Exercises.......................................................................................... 96 Understanding Exit Status..............................................................133
Typing Variables with Declare........................................................ 97 Exercises................................................................................... 135
Array Variables................................................................................98 The If Control Structure.................................................................136
Exercises........................................................................................ 100 Exercises................................................................................... 138
Shell Programming Basics..................................................................101 The CASE Statement..................................................................... 139
Basic Scripting Elements............................................................... 102 Exercises................................................................................... 141
Executeables, Shells & Subshells.................................................. 103 The While and Until Loops............................................................142
Functions versus Scripts................................................................ 105 Exercises................................................................................... 143
Command Lookup Order............................................................... 107 The FOR Loop............................................................................... 144
Reading Script Arguments.............................................................109 Exercises................................................................................... 146
Using shift to Manipulate Arguments............................................110 The select Statement...................................................................... 147
Exercises................................................................................... 111 Exercises................................................................................... 149
Reading Options with getopts........................................................112 Performing String & File I/O Operations........................................... 150
Exercises................................................................................... 114 String I/O....................................................................................... 151
Performing Variable Operations.........................................................115 Processing Input with Read........................................................... 155
Arithmetic Operations....................................................................116 Exercises........................................................................................ 156
Relational Operators...................................................................... 119 Working with Signals......................................................................... 157
Using Variable Substitution Operators.......................................... 121 Understanding Signals................................................................... 158
Using Command Substitution Operators....................................... 123 Defining Signal Handlers...............................................................160
Exercises........................................................................................ 124 Process ID Variables......................................................................162
Flow Control.......................................................................................125 Exercises........................................................................................ 163
What is Flow Control?................................................................... 126 Debugging.......................................................................................... 164

Page 3 of 169
Shell Programming with BASH

Debugging Tools............................................................................165 Questions?.......................................................................................... 168


Using Fake Signals........................................................................ 166 Where to Get Help......................................................................... 169
Exercises........................................................................................ 167

Page 4 of 169

You might also like