Home > Store

Korn Shell Programming by Example

Register your product to gain access to bonus material or receive a coupon.

Korn Shell Programming by Example

Book

  • Sorry, this book is no longer in print.
Not for Sale

Description

  • Copyright 2001
  • Edition: 1st
  • Book
  • ISBN-10: 0-7897-2465-0
  • ISBN-13: 978-0-7897-2465-6

Korn Shell Programming by Example is a straight-forward, nuts and bolts book that will become a standard in the libraries of Unix administrators everywhere because of its real-life examples, progressive style, and lack of unnecessary fluff. Based on the Korn shell, it is an essential reference for administrators on how to program their system, and it is also beneficial for those new to Unix who need to know how to automate their system. Most of all, Korn Shell Programming by Example teaches and arms readers with the ability to solve problems they might encounter.

Sample Content

Table of Contents



Introduction.

Assumptions About the Reader. What This Book Will Give You. What This Book Will Not Give You. Conventions.



1. The Environment.

What Is a Shell? What Is a Shell Script? #!/bin/ksh Explained.

File Attributes. Directories. chmod.

Coming Full Circle-Back to umask. #-Comments Explained. The .profile Script. Aliases. Ksh Environment Options. Variables.

Shell Variables. Built-In Variables. Environment Variables.

Environment File. History File and Repetition.



2. Process Control.

How to Run a Script. Jobs and Processes.

Starting a Process. Stopping a Process. Background. Foreground.

Signals.

Control Key Signals. ps. kill.

nohup Explained. Scheduling Jobs.

cron. at.



3. Variables.

Case Sensitivity. Valid Characters. Scalar.

Accessing. Assigning. typeset. Four Common Errors.

Array.

Declaring. Assigning-Two Ways. Accessing-Two Ways.

Read-Only. Unsetting.



4. Regular Expressions.

Regular Expressions Versus Wildcards. Character Classes. Pattern Matching.

Front. Back.

Metacharacters. Back References.



5. Quoting.

Escape Character.

Asterisk with No Escapes. Asterisk with Escape. Asterisk with No Escapes from a Different Directory. Asterisk with Two Escapes.

Aggregate Quoting Options.

Single Quotes. Double Quotes.

Line Continuation. Command Substitution-Two Ways. Parameter Expansion. Arithmetic Expansion.

Arithmetic Expressions.



6. Flow Control.

If Test.

Exit Status. The (( and [[ Commands. Syntax Options Used for Testing. Commands Within If Tests. One-Line If Tests Using && or ||.

Compound If Tests.

Nested If Tests.

case Conditionals. Looping Constructs.

while Loops. until Loops. for Loops. select Loops.

Loop-Related Commands. Backup Loop Example.



7. Data Manipulation.

Functions.

Command-Line Functions Viewing Functions. Function Arguments Versus Command-Line Arguments. Function Return Values (Integer). Function Return Values (String).

Function Programming Details.

Local Variables. Global Variables. Argument Passing by Reference. Object-Oriented Discipline Functions. Recursive Functions. Using autoload on Functions. Built-In Extension Functions.

Math. Filters. Testing Files.

Testing Strings. Testing Numerals. Testing Numbers. Combining Tests.



8. Information Passing.

Command-Line Arguments. User Input. Redirection. Coprocess.



9. File and Directory Manipulation.

Paths. Descriptors. Special Files. Links. Directories. Hidden Files. Attributes. Permissions. Acceptable Filenames. Accessing Files. Filtering.

head. tail. wc. cat. tee. sort. grep. sed. xargs. awk.

Using Temporary Files.



10. Output Control.

Echoing Output. printf. Output Redirection.

Subshell Output Redirection. Loop Output Redirection.

Multiple Output Redirection. Pipes Versus Redirection. stderr Redirection. Here Documents.



11. Diagnostics.

Syntax Checking. Command Interpretation Sequence. Verbose Mode. Execution Trace. Debugging Hooks.



12. Traps.

Defining and Using Traps. Documentation Support. Self-Help Scripts. Bulletproofing.



13. Pulling It All Together.

The sys_check Script.

Command Options.h. Command Options (Invalid). Command Options.n.

First sys_check Run. Second sys_check Run. Numbered Version of sys_check Script.

Comments on Selected sys_check Lines (10-59). Comments on Selected sys_check Lines (70-102). Comments on Selected sys_check Lines (108-125). Comments on Selected sys_check Lines (130-140). Comments on Selected sys_check Lines (144-204). Comments on Selected sys_check Lines (207-220). Comments on Selected sys_check Lines (222-264). Comments on Selected sys_check Lines (275-281). Comments on Selected sys_check Lines (285-319).



Appendix A. Useful Commands.

alias. autoload. bg. break. builtin. case. cat. cd. chmod. command. continue. cp. cut. date. disown. echo. ed. eval. exec. exit. export. false. fc. fg. find. float. for. function. getconf. getopts. grep. hash. hist. history. if. integer. jobs. kill. [. let. ln. mv. newgrp. nohup. :. paste. print. printf. pwd. r. read. readonly. return. rm. rmdir. script. select. set. shift. sleep. sort. stop. tail. tee. test. time. touch. tr. trap. true. tty. type. typeset. ulimit. umask. unalias. uniq. unset. until. wait. wc. whence. while. who.



Appendix B. vi Tutorial.

Where vi Came From. Starting an Edit Session. Modes of Operation.

Command Mode. Insert Mode.

Last-Line Mode. Exiting from the Editor. Moving the Cursor. Deleting. Cutting and Pasting. Using Multiple Buffers. Searching and Replacing.

Combining Buffers and Substitute Commands.

Changing vi Environment Settings. Edit Session Recovery. Miscellaneous Commands.



Index.

Updates

Submit Errata

More Information

InformIT Promotional Mailings & Special Offers

I would like to receive exclusive offers and hear about products from InformIT and its family of brands. I can unsubscribe at any time.