Linux Shell Scripting – 1 Day

Request info

Linux Shell Scripting

This course gives an introduction to the writing of both Linux and Unix shell scripts using the Bash shell. The course is suitable as preparation for the RHCSA and CompTIA Linux+ examinations.

An editor will be used to create and test shell scripts which will cover the use of variables and arrays, select statements, loop constructs, sub-scripts and functions.

Although based on CentOS (Red Hat) or Ubuntu the commands and principles learnt may be applied to all other versions of Linux, including SUSE and to all versions of Unix including Solaris and AIX.

The course takes the format of a workshop, with a mix of lecture, working examples and practical exercises. Although the content may be customised, at least 1 day is normally needed to cover the core elements.

Full course notes are provided along with sample script files and free software tools for use in accessing a Linux or Unix server.

Pre-requisites

The course is only suitable for those who have a working knowledge of Linux/Unix or have attended the Introduction to Linux/Unix course.

Follow-up

 A natural follow-up to this introductory course would be the Linux Systems Administration course.

On-site Requirements

The course can be run in a class room or in a virtual environment.

There should be no more than 12 delegates on the course and all delegates should meet the above pre-requisites.

Each delegate should have access to a machine running Windows, IOS (Mac) or Linux with at least 2GB of memory and 20GB of free disc space.

The course uses the free software Oracle Virtual Box, which may be installed before the course starts if preferred, and a supplied image file.

If in the class room, an overhead projector that can link to the trainer’s laptop would be a great help.

Content

Overview

Objectives, Schedule, Introductions, Pre-requisites, Responsibilities

Linux Revision

Objectives, Customising the Shell, . – dot Command, Getting Help, Command History, Command Completion, Piping – using | symbol, Redirection – using > symbol, Redirection – using >> symbol, Redirection of Errors – using 2> symbol, Wildcards – File Name Generation, Wildcards – using *, Wildcards – using ?, Wildcards – using [ ], Extended Globbing, Vi and Vim Editors, Using vim, Command Mode – Moving the Cursor, Setting Options, Input/Replace Mode – Inserting/Changing Text, Deleting Text, Other commands, Command-line Mode – Saving/Exiting, Mapping Keys, Saving Settings, Cut and Paste Text – delete and put, Copying Text – yank and put, Comparing Files – cmp, diff, sdiff, vimdiff, Regular Expressions, Global Search Commands, Line Addresses, Global Substitution, Replacing Many Characters, Global Printing and Deleting, Why use vim?, Advanced Commands, find – Finding Files, More on Redirection, Redirecting Errors, Finding Multiple Files, Find and Execute Command, xargs – Passing Filenames, Foreground Jobs, Background Jobs – &, kill – Stopping Jobs, cut – Cropping Text, jobs – Job Control, Scheduling Jobs, Crontab Command, mail – Reading Mail, grep – Finding Text in Files, grep – Using Regular Expressions, egrep – Expression grep, Using Filters, More Regular Expressions, Regular Expression Examples, Permissions – File and Directory, Permissions – Evaluating, chmod – Changing Permissions, chmod – Octal Numbers, SUID Bit, umask – Default File Permissions, umask – Changing Default Permissions

Shell Programming

Objectives, Creating Shell Scripts, Testing the Command, Creating the Script File, Testing the Script, Adding Execute Permissions, The PATH Variable, Login Files, . – dot Command, Passing Parameters, read Command, read in Scripts, Tidying The Output, Choosing the Shell, Debugging the Script

Special Characters and Variables

Objectives, Quotation Marks, Quotes – Double, Single, Quotes – Single, Escape Character, Quotes – Back, Using $(…), Variables – System, Variables – Special, Variables – User, Variables – unset, Variables – declare, Variables in Scripts, Variables – Local, Variables – Global, Variable Constructs – { }, Brackets, Regular Expressions – ( ), { } and [ ], Command Substitution – ( ), Sub-shells – ( ) and { }, Brace Expansion – { }, Other Variable Constructs – { }

Selection

Objectives, if – Conditional Testing, if – File Attributes, if – Using Test, if – Single Square Brackets [ ], If – Logical Constructs [[ ]], if – Multiple Tests, elif, if – NOT Condition, if – Multiple Tests, AND and OR, if – Multiple Tests, Nested, if – Testing Numbers, if – Testing Numbers with (( )), if – Testing Strings, if – Which Construct To Use?, Placing Spaces, Read Command, case – Testing Names, Input validation, If – Regular Expressions, if – Testing Commands, Using Variables

Iteration, Looping

Objectives, let – Computations, () – Computations, expr – Computations, while, until – Iteration, Infinite Loop, for – Iteration, Sequence of Numbers, shift – Moving Parameters, while – Reading a File, while – With a Pipe, for – Iteration using $*, for – at the Command Line, Creating Menus, Objectives, case – Condition Test

Menu Creation

while, until – Iteration, sleep – Holding the Output, read – Holding the Output, exit – Ending the Script, break – Ending the Loop, Hidden Option – Forking a shell, trap – Interrupts, trap – Continue, tput – Highlighting Text, Positioning the Cursor – backtab \b, exec – Running the Script, Select Shell Menu

Arrays, Sub-scripts and Functions

Objectives, Using Arrays, Quoted Strings, Sub-scripts, Export Command, Exit Status, Functions, Creating Functions, Listing Functions, Example Function, Useful Functions, Functions in Scripts, Return Status, Summary

Appendices

Sed Utility

Objectives, sed – Batch Stream Editor, sed – Delete, -d, sed – Regular Expressions, sed – Print, -p, sed – Suppress, -n, sed – Multiple Input, sed – Text Substitutions, sed – Extracting Lines, sed – Updating the File, -i, sed – Multiple Input, sed – File Input, -f, sed – Quit, -q, sed – Example Script

Awk Utility

Objectives, awk Programming Tool, awk – Pattern Matching, awk – Regular Expressions, awk – Delimiter, awk – Contains, awk – Range Patterns, awk – Comparison Patterns, awk – Compound Patterns, awk – Scripts, awk – Troubleshooting Scripts, awk – Built-in Functions, awk – Passing Parameters, awk – Using Contains, awk – Printf Function, awk – Computations, awk – Shortcuts, awk – Functions, substr, length, Self Study, awk – Action Statements, awk – Control Flow Statements, awk – Arrays, awk – Arrays with for Loops, awk – Examples

Advanced Commands

Objectives, eval Command, More on eval, Passing Arguments, Validating Arguments, getopts Command, getopts Example, Debugging the Script

Duration: 1 Day

Cost: £395 + Vat

Linux Training Scotland, Glasgow, Edinburgh, Inverness, Aberdeen and onsite course available throughout the UK.

SELECT wp_posts.*, wp_p2p.* FROM wp_posts INNER JOIN wp_postmeta ON ( wp_posts.ID = wp_postmeta.post_id ) INNER JOIN wp_p2p WHERE 1=1 AND ( ( wp_postmeta.meta_key = 'start_date' AND CAST(wp_postmeta.meta_value AS DATE) >= '2025-04-24' ) ) AND ((wp_posts.post_type = 'schedule' AND (wp_posts.post_status = 'publish' OR wp_posts.post_status = 'acf-disabled'))) AND (wp_p2p.p2p_type = 'schedule_to_courses' AND wp_posts.ID = wp_p2p.p2p_from AND wp_p2p.p2p_to IN (SELECT wp_posts.ID FROM wp_posts WHERE 1=1 AND wp_posts.ID IN (15391) AND ((wp_posts.post_type = 'courses' AND (wp_posts.post_status = 'publish' OR wp_posts.post_status = 'acf-disabled'))) ORDER BY wp_posts.post_date DESC )) GROUP BY wp_posts.ID ORDER BY CAST(wp_postmeta.meta_value AS DATE) ASC