Linux/UNIX Shells and Shell Scripts
Training
Duration
·
40 hours
Pre-Requisites
all mandatory
·
Exposure to some
programming/scripting language
·
Good problem-solving skills
·
Knowledge of basic UNIX/Linux
commands
Target
Audience
·
This course is for programmers
and developers who are familiar with some programming/scripting language and
would like to learn Shell Script
Course
Overview
·
This course will enable the
trainees to appreciate, understand and program using UNIX Shell Scripting
·
There would be sufficient no. of
lab/tutorials sessions to enable hands-on experience with the Linux kernel.
·
Code illustrations and hands-on
would form over 50% of the training duration
·
Training platform can be SSH
access to UNIX/Linux Server or native UNIX/Linux systems
Contents
1.
The
UNIX operating system overview (revision)
1.1. The
UNIX File system
1.2. File system structure
1.3. Directories and files
1.4. Important UNIX directories,
1.5. User's home directory,
1.6. Naming convention
1.7. Accessing Files (Wild-cards, Pathnames)
1.8. Linking
files - inodes, Hard links, Symbolic links
1.9. File system types
1.10.Getting
help man, apropos
1.11.Exercise:
Revisiting common Shell commands/tools
2.
Introduction
to Shell
2.1. Different shells and features
2.2. Invoking a shell
2.3. The PATH
2.4. Quotation marks
2.5. Variables
2.6. Shell variables
2.7. Exporting variables
2.8. Environment variables
2.9.
Process
variables
2.10.What
Is a Shell?
2.11.What
Are Shell Functions?
2.12.The Bourne
Shell
2.13.The Korn Shell
2.14.The
GNU Bourne-Again Shell (Bash)
2.15.Subshells
Child Processes
2.16.What
Is a Shell Script?
2.17.Developing
a Script
2.18.Exercise:
Reviewing UNIX Shells and Shell Scripts
3.
Writing
and Debugging Scripts
3.1. Creating
Shell Scripts
3.2. Executing
a Shell Script
3.3. Executing
the firstscript.sh Script
3.4. Starting
a Script with the #! Characters
3.5. Putting
Comments in a Script
3.6. Adding
the Debugging Statement
3.7. Debug
Mode Controls
3.8. Example:
Debug Mode Specified on the #! Line
3.9. Example:
Debug Mode With the set -x Option
3.10.Example:
Debug Mode With the set -v Option
3.11.Syntax
Comparison for Bourne and Korn Shell Options
3.12.Exercise:
Writing Shell Scripts
4.
The
Shell Environment
4.1. User
Startup Scripts
4.2. The
/etc/profile Script
4.3. The
$HOME/.profile Script
4.4. The
$HOME/.kshrc Script
4.5. Modifying
a Configuration File
5.
Shell
Variables
5.1. Creating
Variables in the Shell
5.2. Exporting
Variables to Subshells
5.3. Reserved
Variables
5.4. Special
Shell Variables
6.
Process
basics
6.1. Checking
on currently running processes
6.2. Process
Identification
6.3. Exit
Status
6.4. Background
Process Identification
7.
Quoting
Characters
7.1. A
Pair of Single Quotes
7.2. A
Pair of Double Quotes
7.3. Backslash
7.4. The eval Command
7.5. Shell
Command Substitution
7.6. Arithmetic
Operations on Shell Variables
7.7. Shell
Aliases
7.8. Removing
Aliases
7.9. Alias
Inheritance
7.10.Built-in
Aliases
7.11.Exercise:
Using the Shell Environment
8.
Regular
Expressions and the grep Command
8.1. The grep Command
8.2. The grep Options
8.3. Regular
Expression Metacharacters
8.4. Regular
Expressions
8.5. Escaping
a Regular Expression
8.6. Line
Anchors
8.7. Word
Anchors
8.8. Character
Classes
8.9. Character
Match
8.10.Closure
(*)
8.11.The egrep Command
8.12.Exercise:
Using Regular Expressions and the grep Command
9.
Conditionals
9.1. The
if Statement
9.2. Parts
of the if Statement
9.3. Command
9.4. Block
of Statements
9.5. End
of the if Statement
9.6. Exit
Status
9.7. Numeric
and String Comparison
9.8. Syntax
for if/then/else Statements
9.9. Syntax
for if/then/elif/else Statements
9.10.Positional
Parameters
9.11.Using
if to Check Command-Line Arguments
9.12.Nested
if Statements
9.13.Testing
File Objects
9.14.Boolean
AND, OR, and NOT Operators
9.15.The
case Statement
9.16.Example
of Using the case Statement
9.17.Replacing
Complex if Statements With a case Statement
9.18.The
exit Statement
9.19.Exercise:
Using Conditionals
10. Interactive Scripts
10.1.Input
and Output in a Script
10.2.The
Shell print Statement
10.3.Examples
of Using the print Statement
10.4.Examples
of Using the echo Statement
10.5.The
read Statement
10.6.Examples
of Using the read Statement
10.7.Capturing
a Command Result
10.8.Printing
a Prompt
10.9.Prompting
for Input Shell Shortcut
10.10.
File Input and Output
10.11.
User-Defined File Descriptors
10.12.
File Descriptors in the Bourne Shell
10.13.
Shell
File Descriptors
10.14.
The
here Document
10.15.
Exercise: Using Interactive Scripts
11. Loops
11.1.Shell
Loops
11.2.The
for Loop Syntax
11.3.The
for Loop Argument List
11.4.Using
an Explicit List to Specify Arguments
11.5.Using
Variable Contents to Specify Arguments
11.6.Using
Command-Line Arguments to Specify Arguments
11.7.Using
Command Substitution to Specify Arguments
11.8.Using
File Names in Command Substitution to Specify Arguments
11.9.Using
File-Name Substitution to Specify Arguments
11.10.
Exercise: Using for Loops
12. The while Loop
12.1.The
while Loop Syntax
12.2.Example
of Using a while Loop
12.3.Keyboard
Input
12.4.Redirecting
Input for a while Loop
12.5.The
until Loop
12.6.The
break Statement
12.7.The
continue Statement
12.8.Example
of Using the continue Statement
12.9.The Shell select Loop
12.10.
The shift Statement
12.11.
Example of Using the shift Statement
12.12.
Exercise: Using Loops and Menus
13. The getopts
Statement
13.1.Processing
Script Options With the getopts Statement
13.2.Using
the getopts Statement
13.3.Handling
Invalid Options
13.4.Specifying
Arguments to Options
13.5.Example
of Using the getopts Statement
13.6.Forgetting
an Argument to an Option
13.7.Exercise:
Using the getopts Statement
14. Advanced Variables, Parameters, and
Argument Lists
14.1.Variable
Types
14.2.Assessing
Variable Values
14.3.The Shell typeset Statement
14.4.Example
of Using String Manipulations
14.5.Declaring
an Integer Variable
14.6.Creating
Bourne Shell Constants
14.7.Creating Shell Constants
14.8.Removing
Portions of a String
14.9.Examples
of Removing Portions of a String
14.10.
Shell Arrays
14.11.
Examples of Using Arrays
14.12.
Using the shift Statement With Positional
Parameters
14.13.
The Values of the $@" and "$*"
Positional Parameters
14.14.
Exercise: Using Advanced Variables,
Parameters, and Argument Lists
15. Functions
15.1.Functions
in the Shell
15.2.Syntax
15.3.Function
Execution
15.4.Positional
Parameters and Functions
15.5.Return
Values
15.6.The
typeset and unset Statements
15.7.Function
Files
15.8.Exercise:
Using Functions
16. Traps
16.1.Shell
Signal Values
16.2.Catching
Signals With the trap Statement
16.3.Example
of Using the trap Statement
16.4.Catching
User Errors With the trap Statement
16.5.Example
of Using the trap Statement With the ERR Signal
16.6.When
to Declare a trap Statement
16.7.Exercise:
Using Traps