Quick Install Links

  • Ubuntu

    Quick install link for the installation of Ubuntu 20.04 LTS.

  • CentOS 8

    Quick link for the installation of CentOS 8.

Course Links

Bash Scripting Tutorial

Welcome to the Land of Linux's Bash Shell Script Tutorial.

The following tutorial will introduce you to the powerful shell scripting language "Bash. The tutorial will cover the basics you will need to start writing simple scripts that can be used to automate processes.

The course links to each section of this course are located on the left hand side of the page.

Part 1 - Bash Shell Scripting Basics

Bash Introduction.
What is Bash? Bourne Again Shell.

What is a Shell?
Internal and External Commands, Type command, Bash Configuration Files - Startup Files.

Bash Shell Command Interpreter
Filename Wildcard Expansion.
Variable Expansion.
Pre Defined Variables.
Command Substitution.
Quotes: Single Quotes and Double Quotes explained.
Backslash - Escape Character.

Output Streams
Standard Input, Standard Output and Standard Error explained.
Redirection and Pipes.

Working with Variables
Assigning values to variables
Using the read command
IFS - Internal Field Separator
env, set, export and unset commands.
Using printf to format output.

Bash Shell Variables
What are Shell Variables?
Special Shell Variables.
Using the shift command.
Using the eval command.

Bash Declare statement.
Changing properties of a variable with declare.
Displaying variable properties with declare -p.

Bash Scripting Basic Structure
Basic Structure of a script.
Using comments.
Handling errors - Custom Error logs.
Execute Permissions using chmod.
$PATH explained.
Adding new paths to $PATH.

Part 2 - Bash Shell Scripting

Debugging and Return Codes
Debugging Bash Scripts. Setting return codes.

What are functions?
Defining functions.
Working with functions.
Calling functions from within scripts.
Creating a functions library.

What are Here Documents?
Here document examples.

What are Here Strings?
Here String examples.

Part 3 - Bash Shell Scripting Basic Structure

Controlling the flow with conditional processing
Bash Scripting if statement
Conditional Processing
"if ..then..elif..then..else..fi
Testing files and objects with "if" statements.

Comparing Strings
String Comparison tests.
Using Single Brackets.
Using Double Brackets.
Using Regular Expressions with Double Brackets.

Bash Scripting Substrings
What are Substrings?
Calculate length of a string.
Extracting a substring from a variable.
Replacing matches within substrings.

Comparing Numbers
Numerical Operators.
Integer Operators.
Testing numeric values and working with numbers.

Boolean Operators
Logical Boolean Operators.
Logical Negation, Logical AND, Logical OR.
Combining Logical Operators.

Bash Scripting Case Statements
Using Case statements to simplify logic within a script.
Pattern matching with case statements.
Mixed case pattern matching using the case statement.

Part 4 - Using Loops within Bash Shell Scripts

Bash Scripting for loop
for loop examples.
Using the for loop within a script.

Bash Scripting while loop
while loop examples.
Using the while loop within a script.

Bash Scripting until loop
until loop examples.
Using the until loop within a script.

Exiting loops
Examples of how to exit a loop.
Using the break command to exit a loop.

Continue Command
Examples of how to use the continue command within a loop.
Continue to the next iteration within a loop.

Part 5 - Number and Arithmetic

Making calculations in Bash
Number and Arithmetic
Mathematical Operations within Bash.
Arithmetic Operators.
Addition, Subtraction, Division and Multiplication.
Using Modulo command - modulo example.
Exponentiation - exponentiation example.
BC - Bash built in arbitrary precision calculator.
Mathematical Functions.
Invoking the Math library.

Part 6 - Arrays

Working with arrays
What is an array?
Array assignment.
Deleting arrays with the unset command.
Bash array example scripts.

Part 7 - Interactive Scripts

Interactive Scripts
Getting User Input
Create interactive scripts.
Using the read command.
Simple Menus with echo and read commands.
Select Statement
Using Select.
Create interactive menus with select statement.
Combining select and case statements to create menus.