Linux Shell Scripting

Contact Us for Dates
3 days practical workshop for up to 12 people.
Only £1185
A 3 day course describing how to develop Linux shell scripts using the programming features of the Bash or Korn shells. This course covers the shell command line, command line parsing, meta characters, I/O redirection, pipelines, quotes, variable substitution, conditional flow control, looping, process substitution. The focus is on using best practices and techniques to develop professional quality scripts. Optionally this course can be customized by combining it with the companion course Linux Command Line Essentials.

Layout

This course comprises a mix of theory, demonstrations and hands on exercises. Approximately 50% of the time is hands-on.

Training Course Objectives

  • Understanding the command line parsing rules
  • Working effectively with variables, wildcards and quotes
  • Building command lines using I/O redirection and pipelines
  • Making decisions with the if and test commands
  • Looping with the for and while commands
  • Choosing alternatives with the case and select commands
  • Defining and calling functions
  • Using advanced variable and command substitution

Who it is for

People who need to be able to write and maintain linux shell scripts.

Training Course Prerequisites

  • This course is designed for staff with experience of the Linux command line who are able to edit and save text files. A basic knowledge of programming constructs such as variables, conditional flow control and looping obtained from prior experience of another scripting or programming language is essential.

Chapters

Chapter 1 Introduction to shell scripts

  • Creating and executing scripts
  • The source command
  • Using the #! (shebang) construct
  • Debugging and tracing scripts
  • Common features of Korn Shell and Bash

Chapter 2 Environment variables

  • Review of variables and quotes
  • Local and environment variables
  • Review of I/O streams and pipelines
  • The print and read commands
  • Working with shell history

Chapter 3 Conditional flow

  • The exit command and process status
  • The if command
  • The test command and [[
  • Using the semi-colon command separator
  • Numeric variables

Chapter 4 Looping

  • The while and until command
  • The for command
  • Compound I/O redirection

Chapter 5 Running commands

  • Builtin commands
  • Useful external commands
  • Filter commands and utilities
  • Aliases and profiles

Chapter 6 The command line

  • Command line arguments
  • The shift command and $*, $@
  • The getopts command
  • Array variables

Chapter 7 Functions

  • Defining functions
  • Function parameters and return values
  • Sub shells

Chapter 8 Handling text

  • Command substitution (backquotes)
  • Pattern matching variable substitution
  • Here documents

Chapter 9 Menus

  • The select command
  • Using the prompt variables
  • The case command