Problem Solving with Shell Scripts

Accelerated Technical Training for Programmers and Power Users

Format

  • 1 full day
  • Emphasis on practical skills.
  • Hands-on.

Audience

  • programmers
  • software applications developers
  • system administrators
  • webmasters
  • tool builders

Overview

This course is for Unix users (and users of Unix-like shells on other systems) who want to increase their mastery of this powerful repertory of problem-solving tools and techniques.

Its primary goal is to impart the skills needed to use advanced features of the Bourne and Korn shells, in particular their use as a programming language and environment. A C-Shell-oriented version of this course is also available.

Shell programming skills enable extraordinary productivity gains.

Familiarity with the basic concepts of programming is helpful but not required.

In its method, the course's emphasis is on the practical, with the majority of the classroom time devoted to hands-on activity. Attendees largely set their own paces, with the instructor acting mainly as a facilitator.

Historical and theoretical material is kept to a minimum.

Prerequisites

  • using the window system -- moving windows, resizing them, opening new ones
  • using an editor -- it doesn't have to be vi
  • helpful but not required:
    • editing the command line -- a feature of the Korn shell and the C shell that can save keystrokes
    • understanding the purpose and mechanism of a shell

Objectives

Upon completion of this course, you will be able to apply many of Unix's advanced commands, including:
  • grep to search
  • pr to format
  • expr to calculate
  • sed to edit
  • awk to process records
  • various other commands including date, echo, lp, ls, man, more, sort, and wc
  • exploit powerful shell features:
    • redirection
    • command substitution
    • inter-process communication (pipes)
    • file name generation
    • variable substitution
    • loops, tests, branches
  • create and execute shell scripts
  • construct complex commands (options, arguments, metacharacters)
  • match patterns with regular expressions
  • perform arithmetic operations
  • use Unix's "man page" documentation
  • add shell programming to your repertory of problem-solving techniques

Method

The course consists of a sequence of examples and hands-on exercises. Each builds on the ones before it. By the end of the course, you have built solutions to significant problems.

Contents

  1. Housekeeping
    • review of prerequisites
    • course objectives
    • related topics
  2. Why Shell Scripts?
    • this is why programmers fall in love with Unix
    • similar concepts from other environments
  3. Review of Prerequisite Topics
    • command-line editing
    • vi (or emacs or whatever's preferred)
  4. Philosophy
    • Unix's "building blocks" approach
    • silence is golden
  5. Documentation
    • what's in a man page
    • how they're organized
    • why they're effective
  6. man - Unix's On-Line Manual
    • how to use it
    • special case: shell built-in commands
  7. The ls Command
    • some options
  8. File Name Wildcards
    • * and ?
  9. The cat Command
    • notions of stdin, stdout, stderr
  10. The more Command
    • pagers and how to use them
  11. The date Command
  12. Output Redirection
    • using the >
  13. Output Redirection with Append
    • using the >>
  14. The echo Command
    • surprisingly useful (for *, ?, $, etc.)
  15. Shell Variables
    • using the $
  16. Command Substitution
    • an essential technique
  17. The wc Command
    • measuring sizes of files
    • counting things
  18. Command Options
    • tailoring your commands
  19. Pipes
    • Unix plumbing
  20. The pr Command
    • rudimentary formatting
    • some special techniques
  21. The lp Command
    • printing
  22. The sort Command
  23. Summary of Data Movement Techniques
    • moving data between files, streams, variables, devices
  24. Creating and Running a Shell Script
    • the chmod command
    • the $PATH variable
  25. A Non-Trivial Example
    • building a simple bookkeeping system
  26. The grep Command
    • extracting text patterns
    • regular expressions
  27. The sed Command
    • stream editing
  28. More Regular Expressions
  29. Shell Script Loops
    • shell programming control structures
  30. Shell Script Arithmetic
    • the expr command
  31. The awk Command
    • processing fields and records
  32. Summary

Classroom Setup

Delivery of this course requires a classroom equipped with:
  1. an overhead projector
  2. a PC or workstation for each student
  3. connection to the internet
  4. a workbook for each student
Travel outside the San Francisco Bay Area requires reimbursement of the instructor's travel expense.

Copyright © 2020

Dan Keller Technical Services
2248 International Blvd., Oakland
California, USA 94606
tel: 415 / 861-4500