Log In
Or create an account ->
Imperial Library
Home
About
News
Upload
Forum
Help
Login/SignUp
Index
Learning the Korn Shell, 2nd Edition
Dedication
A Note Regarding Supplemental Files
Preface
Korn Shell Versions
Summary of Korn Shell Features
Intended Audience
Code Examples
Chapter Summary
Conventions Used in This Handbook
About the Second Edition
We’d Like to Hear From You
Acknowledgments
Acknowledgments from the First Edition
1. Korn Shell Basics
What Is a Shell?
Scope of This Book
History of Unix Shells
The Korn Shell
Features of the Korn Shell
Getting the 1993 Korn Shell
Interactive Shell Use
Commands, Arguments, and Options
Built-in Help
Files
Directories
The working directory
Tilde notation
Changing working directories
Symbolic links to directories
Filenames and Wildcards
Input and Output
Standard I/O
I/O Redirection
Pipelines
Background Jobs
Background I/O
Background Jobs and Priorities
nice
Special Characters and Quoting
Quoting
Backslash-Escaping
Quoting Quotation Marks
Continuing Lines
Control Keys
2. Command-Line Editing
Enabling Command-Line Editing
The History File
Emacs Editing Mode
Basic Commands
Word Commands
Line Commands
Moving Around in the History File
Filename and Variable Completion and Expansion
Miscellaneous Commands
Macro Expansion with Aliases
Vi Editing Mode
Simple Control Mode Commands
Entering and Changing Text
Deletion Commands
Moving Around in the History File
Character-Finding Commands
Filename and Variable Completion and Expansion
Miscellaneous Commands
Macro Expansion with Aliases
The hist Command
Finger Habits
3. Customizing Your Environment
The .profile File
The /etc/profile File
Aliases
Options
Shell Variables
Variables and Quoting
Built-in Variables
Editing mode variables
Mail variables
Prompting variables
Using history command numbers
Terminal types
Command search path
PATH security considerations
PATH and tracked aliases
Directory search path
Miscellaneous variables
Customization and Subprocesses
Environment Variables
The Environment File
Customization Hints
4. Basic Shell Programming
Shell Scripts and Functions
Functions
Automatically loading functions
POSIX functions
Shell Variables
Positional Parameters
Positional parameters in functions
Changing the positional parameters
More on Variable Syntax
Appending to a Variable
Compound Variables
Compound Variable Assignment
Indirect Variable References (namerefs)
String Operators
Syntax of String Operators
Patterns and Regular Expressions
Regular expression basics
POSIX character class additions
Korn shell versus awk/egrep regular expressions
Pattern matching with regular expressions
Pattern-Matching Operators
Pattern Substitution Operators
Greedy versus non-greedy matching
Variable Name Operators
Length Operators
The .sh.match Variable
Command Substitution
Advanced Examples: pushd and popd
5. Flow Control
if/else
Exit Status and Return
Return
Advanced example: overriding a built-in command
Pipeline exit status
Interpreting exit status values
Combinations of Exit Statuses
Reversing the Sense of a Test
Condition Tests
String comparisons
About C compilers
File attribute checking
Arithmetic conditionals
for
case
Merging Cases
select
while and until
break and continue
6. Command-Line Options and Typed Variables
Command-Line Options
shift
Options with Arguments
getopts
More about C compilers
Numeric Variables and Arithmetic
Built-in Arithmetic Functions
Arithmetic Conditionals
Arithmetic Variables and Assignment
Arithmetic for
Arrays
Indexed Arrays
Associative Arrays
Array Name Operators
typeset
Local Variables in Functions
String Formatting Options
Type and Attribute Options
Function Options
7. Input/Output and Command-Line Processing
I/O Redirectors
Here-Documents
Here-Strings
File Descriptors
Redirector ordering
Special Filenames
String I/O
print
print escape sequences
Options to print
printf
Additional Korn shell printf specifiers
read
Reading lines from files
I/O redirection and multiple commands
Code blocks
Reading user input
Options to read
Command-Line Processing
Brace Expansion and Process Substitution
Substitution Order
Quoting
Extended quoting
eval
The C compiler as pipeline
8. Process Handling
Process IDs and Job Numbers
Job Control
Foreground and Background
Suspending a Job
Disowning a Job
Signals
Control-Key Signals
kill
ps
System V
BSD
kill: The Full Story
trap
Traps and Functions
Process ID Variables and Temporary Files
Ignoring Signals
Resetting Traps
Coroutines
wait
Advantages and Disadvantages of Coroutines
Parallelization
Coroutines with Two-Way Pipes
Two-Way Pipes Versus Standard Pipes
Shell Subprocesses and Subshells
Shell Subprocess Inheritance
Subshells
9. Debugging Shell Programs
Basic Debugging Aids
Set Options
Fake Signals
EXIT
ERR
DEBUG
Signal delivery order
Discipline Functions
A Korn Shell Debugger
Structure of the Debugger
The driver script
exec
The Preamble
Debugger Functions
Commands
Stepping
Breakpoints
Break conditions
Execution tracing
Watchpoints
Limitations
A Sample kshdb Session
Exercises
10. Korn Shell Administration
Installing the Korn Shell as the Standard Shell
Environment Customization
umask
ulimit
Types of Global Customization
Customizing the Editing Modes
System Security Features
Tips for Secure Shell Scripts
Restricted Shell
Trojan Horses
Setuid and Privileged Mode
A. Related Shells
The Bourne Shell
The 1988 Korn Shell
The IEEE 1003.2 POSIX Shell Standard
dtksh
tksh
pdksh
bash
zsh
Extended Globbing
Completion
Command-Line Editor
Prompts and Prompt Themes
Differences Between zsh and ksh
Workalikes on PC Platforms
Cygwin
DJGPP
MKS Toolkit
Thompson Automation Software Toolkit
AT&T UWIN
B. Reference Information
Invocation Options
Built-in Commands and Keywords
Predefined Aliases
Built-in Shell Variables
Test Operators
Options
Typeset Options
Arithmetic
Emacs Mode Commands
vi Control Mode Commands
Using getopts
C. Building ksh from Source Code
Korn Shell Web Sites
What You Can Download
Building ksh
D. AT&T ast Source Code License Agreement
Index
About the Authors
Colophon
Copyright
← Prev
Back
Next →
← Prev
Back
Next →