Korn Shell Programming Essentials
Duration
Three Days
Description
This course is designed to help technical staff learn the essential skills needed to maintain, write and debug UNIX Korn shell shell scripts. Both the widely available Korn Shell 88 and newer KornShell 93 are covered, with hands-on programming exercises highlighting techniques for each shell.
Topics
- Introduction to Shell Programming
- Review of UNIX Essentials
- Review of the vi editor
- Korn Shell Programming Essentials
Audience
This course is intended for technical staff that develops and maintains UNIX Korn shell programs either for personal productivity, as an aid to application development or for advanced UNIX system monitoring and maintenance.
Pre-requisites
The student should have completed the ProTech UNIX Systems Basics I course or possess equivalent knowledge including an understanding of the UNIX file system, permissions, basic file management commands, use of the vi editor and familiarity with using a UNIX shell interactively.
Course Outline
Intro to the UNIX Shell
- The UNIX Shell
- Key Shell Features
- Different Shell Flavors
- The Shell Prompt
- Intro to Shell Variables
- Creating & Using Shell Variables
- The Environment & Shell Variables
- Exporting Shell Variables
- Useful Shell Variables
- Understanding Shell Quote Usage
- Command-line Editing
- Shell Initialization: Startup Scripts
- Shell Initialization Variables: Lab
- Shell Scripts
- Shell Scripts - Example
- Languages: Compiled vs. Scripting
- Viewing Exit Status in the Shell
- Using Exit Status in a Shell Script
- Shell: Redirection to & from Files
- Shell: Pipes
- Shell: Wildcards
- Shell: Command Alias
- UNIX Process Management
- UNIX Process Mgmt: the ps cmd
- UNIX Process Mgmt: Background
- Shell Job Control Commands
- UNIX Process Mgmt: Kill
- UNIX Process Management Lab
Review of UNIX Essentials
- A. Review of UNIX Essentials
- UNIX Command Overview
- Logging In
- Changing your Password
- Logging Out
- Commands, Switches, and Arguments
- Reading the Manual: the man cmd
- Userid, UID, Group, GID
- Understanding UNIX Permissions
- The UNIX File System
- Home and Working Directory
- Commands to List Contents of A File
- head and tail Commands
- Copying and Moving Files
- Deleting Files
- Summary Slide (cont.)
- UNIX Filenames
- File Management Lab
- Creating Directories
- Removing Directories
- Copying Files Between Directories
- UNIX File Security: Permissions
- Working with Permissions
- chmod Examples
- UNIX Directory Permissions
- Lab: chmod
- File/Dir Permissions - umask
- Changing File Ownership
- Under the covers of the File System
- File Systems, inodes, vnodes
- Linking files
- Hard vs. Symbolic Links
- Linking to a file - ln
- UNIX Power Tools
- Finding Files
- UNIX Power Tools: sort
- Archiving Files
- Compressing files
- TCP/IP Networking
- TCP/IP Diagnostic Commands
- TCP/IP Applications: rsh, rexec, ftp, mail
- Example FTP Session
- TCP/IP Applications: write
- TCP/IP Applications: wall
- TCP/IP Applications: talk
- Scheduling Work w/ cron & at
Review of the vi Editor
- UNIX Text Editors
- Editing Files with vi - Modes
- Editing Files with vi - Scrolling
- Editing Files with vi - Editing
- Editing Files with vi - File cmds
- Editing Files with vi - .exrc
- vi: Lab
- vi: Regular Expressions
- vi: Regular Expression Examples
- vi: Searching for Text
- vi: Search Lab
- vi: Text Substitution
- vi: Text Substitution Lab
Korn Shell Programming Essentials
- What are the Korn Shell Versions?
- Korn Shell Syntax Example
- Using the print Command
- Using Korn Shell Variables
- KornShell Variable Types
- typeset Command
- typeset for Mathematics
- Defining and Using Array Variables
- Reading User Input: Ksh88 & Ksh93 Examples
- Korn Shell Arithmetic
- Korn Shell Arithmetic Operators
- Korn Shell Arithmetic: Lab
- Command Line Arguments
- Command Line Arguments: Example
- Condition Testing: if/then/elif/else
- Condition Testing: [[ ]] command
- String Condition Testing: Example
- String Testing: Pattern Example
- Compound Condition Testing
- Condition Testing: Optional Lab
- Conditional Execution
- Exiting from a script
- File Validation & Exit: Optional Lab
- Condition Testing: case/esac
- Looping Overview: for
- Looping Overview: while and until
- for Loop: User List Example
- for Loop: Filename Expansion
- for Loop: Counting…
- while Loop
- Nested while Loops
- Infinite Loops with while
- Infinite Loops: Optional Lab
- while Loops: Optional Lab
- File I/O Overview
- Shell Statement Redirection Syntax
- Redirecting the Shell with exec
- File I/O: Optional Lab
- Shell Statement Piping Syntax
- Shell Statement Piping: Example
- Multitasking in a Shell Program