Skip to main content

Instructor-led training

Shell Programming Training in Kingsburg, California

Private .NET training for organizations from Hartmann Software Group, delivered onsite in Kingsburg, California or live online.

What you'll learn

Shell programs, or scripts, are the means by which a UNIX™ shell is used as a programming language. UNIX commands and shell language control constructs are entered into a file by the programmer, then the file is executed as a command and interpreted just as if the commands had been typed on the shell command line. Thus, shell scripts provide a way to automate commonly executed groups of commands - but shell scripts can do much more than this. Although many simple tasks are automated with small scripts, large scripts hundreds of lines long are very common. These larger scripts are written by system administrators, database administrators, testers, utility programmers, and others to create utilities that are largely composed of powerful UNIX commands, such as find, sed, awk, and hundreds of others. In this course, students learn to read, write, and debug Korn shell scripts. Back at work they can greatly increase productivity by automating repetitive tasks (for themselves or others), and by creating specifically tailored utilities designed to meet their precise needs. Students will read and write many shell scripts in this class, which will additionally increase their overall UNIX knowledge and skills.

Private Training for Teams

This course is offered as private, instructor-led training for organizations, onsite in Kingsburg, California or live online. Dates, delivery format, and course content are arranged around your team's requirements.

This course is not currently scheduled as a public class for individual enrollment.

Request Group Training

Prerequisites

Fundamentals of UNIX.

Course Outline

Course Introduction
 
Course Objectives
Course Overview
Using the Workbook
Suggested References
 
UNIX Processes
What is a Process?
Process Structure
The ps Utility
ps Options
Background Command
Killing Background Processes
Redirecting the Standard Process
Labs
 
Getting Started
What is a Shell?
Running Scripts
Specifying the Script's Interpreter
The PATH variable
Sub-shells
Labs
 
Variables
Shell Variables
The read Command
The export Command
The Shell Environment
Variable Substitution
Command Substitution
Labs
 
The Login Process
The Login Process
The System Profile Script
The .profile Script
The . Command
Labs
 
Conditional Statements
The Exit Status of Commands
Command Line Examples
The test Command
The if-then-else Construct
The elif Command
case Statements
Labs
 
Loops
The for Loop
The while Loop
break and continue
Reading Lines From Files
Using Arrays with Loops
Labs
 
Special Variables
$$ - PID of Shell
Command-Line Arguments
$# - Number of Arguments
$* - All Arguments
The shift Command
The set Command
Getting Options
Labs
 
Quoting Mechanisms
Single vs. Double Quotes
What is a Here Document?
Using a Here Document
Here Document Quoting
Ignoring Leading Tabs
Labs
 
Functions
Shell Functions
Passing Arguments to Functions
Returning Values from Functions
Function Libraries
Labs
 
Advanced Programming
Shell Arithmetic
The select Statement
Terminal Independence in Scripts
The eval Command
Labs
 
Debugging Techniques
Using echo
Using Standard Error
Options for Debugging
Script Tracing
Conditional Debugging
Labs
 
Shell IPC
Co-processes
The print and read Commands
Signals
The trap Command
Named Pipes
The wait Command
Labs

What makes shell programming hard to master

The commands are short, so the course looks easy. The difficulty is that a shell script is interpreted text, and the shell rewrites that text several times before anything runs. The syllabus builds these layers in order.

  • Processes and environment first. UNIX Processes (the ps utility, background commands, killing background processes) and Getting Started (sub-shells, the PATH variable, specifying the script's interpreter) explain why a script behaves differently from the same commands typed interactively. Variables, export and the login scripts (.profile, the . command) then show which variables a child process inherits.
  • Substitution and quoting. Variable and command substitution, single versus double quotes, and here documents (including here document quoting and ignoring leading tabs) cause most beginner bugs. A common misconception is that quotes only group words. In fact they decide which expansions happen at all.
  • Exit status as the control signal. Conditionals are driven by the exit status of commands, not by boolean values. test, if/elif and case follow from that idea, as do the while loop and reading lines from files.
  • Arguments and structure. Special variables ($#, $*, shift, set, getting options) feed into shell functions, argument passing, returning values and function libraries.
  • Advanced and concurrent behavior. Shell arithmetic, select, eval, co-processes, signals, trap, named pipes and wait are where timing and cleanup problems appear. The debugging unit (script tracing, conditional debugging, using standard error) supplies the tools to diagnose them.

Who it suits and what to take around it

The course targets system administrators, database administrators, testers and utility programmers who already work at a UNIX command line. The stated prerequisite is Fundamentals of UNIX. You should be comfortable with files, directories, pipes and redirection before you start, because the course spends its time on the shell as a language. The description focuses on Korn shell scripts.

For people who also script Windows administration, AZ-040: Automating Administration with PowerShell is a reasonable follow-on. It applies the same habits (automating repeated tasks, composing small tools, handling errors) in an object-based shell. The .NET courses and learning guide lists the other courses in this category.

Illustrative scenarios

The scenarios below are illustrations of how the course material can be applied. They are not descriptions of specific organizations or of the course's lab exercises.

  • Housekeeping utility. A team might write a script that loops over a list of files, reads configuration lines with a while loop, tests each command's exit status, and branches with case on the result. It would use functions kept in a function library and stderr output for failures.
  • Reusable command wrapper. An administrator might wrap a long command in a script that accepts options, shifts through its arguments and builds output with a here document. Sourcing a shared .profile-style file would set up the environment consistently.
  • Coordinated background jobs. A script might start several background processes, record their PIDs, use wait to collect them, and use trap to clean up temporary files and named pipes when interrupted.

AI coding assistants and shell scripts

AI coding assistants draft short scripts quickly and can explain an unfamiliar one-liner. They are weaker on the points this course emphasizes.

  • Dialect drift. Generated scripts often assume features of another shell, such as different array syntax, extended test brackets or different read options. The result may fail under the interpreter named on the script's first line.
  • Quoting and word splitting. Unquoted variables, wrong quote types and misplaced command substitution can work on simple test data and break on filenames with spaces.
  • Risky constructs. Suggestions may use eval on unchecked input or omit trap cleanup. They may also ignore exit status, so a failing step is silently skipped.

To verify, run the script with the interpreter it declares and trace it using the debugging options covered in the course. Test with awkward input such as empty values, spaces and missing files. Check every branch of exit-status logic, and interrupt the script to confirm that signal handling cleans up. Reading and debugging scripts, which this course practices throughout, is the skill that makes this review reliable.

Frequently asked questions

What level is this course?

It is a general-level, three-day course for people who already use the UNIX command line and want to write, read and debug Korn shell scripts.

What should I know beforehand?

The listed prerequisite is Fundamentals of UNIX. You should be comfortable navigating the file system, running commands, and using pipes and redirection.

What does the course cover?

It covers processes, variables and the environment, login scripts, conditionals, loops, special variables and options, quoting and here documents, functions, arithmetic, debugging techniques, and shell IPC (co-processes, signals, trap, named pipes, wait). Each unit includes labs.

Can this be delivered privately for our team?

Yes. HSG delivers private training onsite at the client's location or live online.

Can the content be customized?

Private training can be tailored to your team's environment and the tools and versions you use. You can request a training proposal to discuss your needs.

Training locations

Shell Programming training across the U.S. and beyond.

We provide private Shell Programming training for organizations, onsite at your location or live online, throughout the United States and internationally.

View all Shell Programming training locations

Train your team with HSG

Private, instructor-led training customized for your organization.

  • Onsite or live online delivery
  • Customized curriculum
  • For a single employee or an entire team
  • Flexible scheduling
  • Experienced instructors
Request Group Training

Questions? Call us at 303.377.6176
or email info@hartmannsoftware.com

Ready to train your team?

Let's customize this training for your organization.

Tell us about your employees, your goals, and your preferred schedule. We'll prepare a training proposal covering scope, delivery format, and pricing.