First Technology Transfer

Standard and Advanced Technical Training, Consultancy and Mentoring

Linux Tools Utilities and Bash Scripting

Duration: 4 Days

Intended Audience

This course is an in depth course that explores the capabilities of BASH and in conjunction with Linux/Unix command line tools and utilities commonly used in the development of shell scripts. This course is aimed at programmers and analysts operating in Linux/Unix environments using BASH, as well as Unix system and network administrators. Although based on Linux, this course is applicable to most flavours of UNIX including Linux, HP-UX, Solaris, and AIX.

Prerequisites

Attendees are assumed to have a good working knowledge of Linux or UNIX systems. This includes a working knowledge of UNIX commands and utilities. Attendees are, also, assumed to have a practical understanding of programming concepts such as variables, choice using if .. else and related constructs, and iteration using for loops and while loops.

Key topics covered

  • BASH language - syntax and common scripting idioms
  • Advanced variable and array manipulation
  • Structured shell scripts that contain advanced decision making constructs
  • Use of tracing features to debug shell scripts
  • Implementation of advanced data stream handling by making use of process substitution
  • Structured Bash scripting via use of functions
  • Integrate BASH scripts with scripts written in other languages e.g. Python, awk
  • Designing and implementing scripts with testability, maintainability and efficiency in mind

Detailed Course Outline

  • Command line commands - syntax, structure and processing
    • Command-line structure and syntax
    • Shell interpretation steps
    • Filename expansion
    • Variable and command expansions
    • Quoting
    • Redirection
    • Here documents
    • Pipes
  • Working with BASH

    • Shell command line options
    • Bash shell command line options
    • Start-up files
    • Builtin shell variables
    • Aliases and functions
    • Command-line history recall and editing
    • echo and help
  • Shell Scripts
    • Creating shell scripts
    • The #! notation (shebang notation)
    • Creating processes
    • The exec command
    • Exit status
    • Commenting using # in shell scripts
    • Running shell scripts
    • BASH_ENV
    • Command groups and sub-shells
  • Shell Variables

    • Legal variable names
    • Creating variables
    • The read command
    • Exporting variables
    • Special characters
    • Checking the environment
    • eval
  • Parameters and Builtin Variables

    • Positional parameters
    • Access to positional parameters
    • $*, $@, and $#
    • Changing positional aparmeters
    • $* versus $@
    • Other special variables
  • Controlling and Debugging Scripts

    • Sending signals,
    • Receiving and handling signals using the trap command
    • Shell tracing techniques
    • Tracing shell expansions
    • DEBUG and ERR traps
    • Performing a Dry run of a script
    • The script command
    • Interpreting Error messages when testing and debugging scripts
  • Flow Control - Choice and Iteration
    • Testing commands
    • 'if' statements
    • 'while' and 'until' loops
    • Bourne shell test command
    • Korn shell test command
    • Bourne and Korn syntax compared
    • Numeric tests
  • Variable Expansion/Substitution
    • Extracting a sub-string
    • Deleting a sub-string
    • Editing sub-strings
    • Test and set/exit expansions
    • The colon command
  • Variables - Advanced Topic
    • Variable attributes
    • Compound assignments
    • Arithmetic conditionals
    • Working with floating-point values
  • Iteration - In Depth
    • List processing - 'for' loop
    • Processing positional parameters
    • 'break' and 'continue'
    • Infinite loops
    • The 'select' loop
    • Reading in a loop from a file
    • Reading in a loop from a program (process substitution)
  • Advanced Testing and Branching

    • Statement short-cuts
    • I/O redirection with if-then-fi
    • The 'case' statement
    • case flow control - Bash 4
    • Shell pattern matching
    • Extended pattern operators
    • Locales and character classes
  • Functions and Structured Shell Scripting

    • Functions vs. scripts
    • Defining/implementing functions
    • Listing and removing functions
    • Function parameters and return values
    • Local and global variables
    • Storing functions - locally vs. storing in external files
    • Exported functions
    • Using external function libraries
  • Advanced Scripts

    • Parsing script options with getopts
    • Handling errors
    • Formatting output - printf
    • Programming for maintainability and reusability
    • Programming for performance
  • Advanced Arrays and Array Handling

    • Arrays in Bash
    • Bash array syntax
    • Initialising arrays
    • Appending to an array
    • Finding array limits
    • Using read with an array
    • Using mapfile/readarray
    • Associative arrays
  • Advanced IO
    • Using file descriptors
    • Block redirection
    • Named pipes (FIFOs)
    • Process substitution
  • sed Scripting and combining sed with bash
    • Running sed
    • Basic regular expressions
    • sed line addressing
  • awk Scripting and combining awk with bash

    • The awk programming model
    • awk variables
    • awk opeators
    • Comparing awk with shell constructs
  • Overview of Combining Bash and Python

    • Overview of Python and its many packages
    • Invoking Python scripts from with Bash
    • Invoking Bash scripts from within Python
    • Some examples and demonstrations

Note: We can and have run bespoke advanced Bash + Python combined Courses.

Call us:

Technical enqiries: 020 8669 0769
Sales enquiries: 020 8647 1939, 020 77681 40786