Learning the Korn Shell

Book description

This Nutshell Handbook(R) is a thorough introduction to the Korn shell, both as a user interface and as a programming language.The Korn shell, like the C and Bourne shells, is a program that interprets UNIX commands. It has many features that aren't found in other shells, including command history (the ability to recall and edit previous commands). The Korn shell is also faster; several of its features allow you to write programs that execute more quickly than their Bourne or C shell equivalents.This book provides a clear and concise explanation of the Korn shell's features. It explains ksh string operations, co-processes, signals and signal handling, and one of the worst "dark corners" of shell programming: command-line interpretation. It does this by introducing simple real-life examples and then adding options and complexity in later chapters, illustrating the way real-world script development generally proceeds. An additional (and unique) programming aid, a Korn shell debugger (kshdb), is also included.Learning the Korn Shell is an ideal resource for many UNIX users and programmers, including software developers who want to "prototype" their designs, system administrators who want to write tools for their own use, and even novices who just want to use some of ksh's more advanced interactive features.

Publisher resources

View/Submit Errata

Table of contents

  1. A Note Regarding Supplemental Files
  2. Preface
    1. Korn Shell Versions
    2. Summary of Korn Shell Features
    3. Intended Audience
    4. Code Examples
    5. Chapter Summary
    6. Conventions Used in This Handbook
    7. Acknowledgments
    8. We’d Like to Hear From You
  3. 1. Korn Shell Basics
    1. What Is a Shell?
    2. Scope of This Book
    3. History of UNIX Shells
      1. The Korn Shell
      2. Features of the Korn Shell
    4. Getting the Korn Shell
    5. Interactive Shell Use
      1. Commands, Arguments, and Options
    6. Files
      1. Directories
        1. The working directory
        2. Tilde notation
        3. Changing working directories
      2. Filenames and Wildcards
    7. Input and Output
      1. Standard I/O
      2. I/O Redirection
      3. Pipelines
    8. Background Jobs
      1. Background I/O
      2. Background Jobs and Priorities
        1. nice
    9. Special Characters and Quoting
      1. Quoting
      2. Backslash-escaping
      3. Quoting Quotation Marks
      4. Continuing Lines
      5. Control Keys
  4. 2. Command-line Editing
    1. Enabling Command-line Editing
    2. The History File
    3. Emacs Editing Mode
      1. Basic Commands
      2. Word Commands
      3. Line Commands
      4. Moving Around in the History File
      5. Filename Completion and Expansion
      6. Miscellaneous Commands
      7. Keyboard Shortcuts with Aliases
    4. Vi Editing Mode
      1. Simple Control Mode Commands
      2. Entering and Changing Text
      3. Deletion Commands
      4. Moving Around in the History File
      5. Character-finding Commands
      6. Filename Completion
      7. Miscellaneous Commands
    5. The fc Command
    6. Finger Habits
  5. 3. Customizing Your Environment
    1. The .profile File
    2. Aliases
      1. Tracked Aliases
    3. Options
    4. Shell Variables
      1. Variables and Quoting
      2. Built-in Variables
        1. Editing mode variables
        2. Mail Variables
        3. Prompting Variables
        4. Terminal Types
        5. Command Search Path
        6. PATH and Tracked Aliases
      3. Directory Search Path
        1. Miscellaneous Variables
    5. Customization and Subprocesses
      1. Environment Variables
      2. The Environment File
    6. Customization Hints
  6. 4. Basic Shell Programming
    1. Shell Scripts and Functions
      1. Functions
        1. Autoloaded functions
    2. Shell Variables
      1. Positional Parameters
        1. Positional parameters in functions
      2. More on Variable Syntax
    3. String Operators
      1. Syntax of String Operators
      2. Patterns and Regular Expressions
        1. Regular expression basics
        2. Korn shell versus awk/egrep regular expressions
      3. Pattern-matching Operators
      4. Length Operator
    4. Command Substitution
    5. Advanced Examples: pushd and popd
  7. 5. Flow Control
    1. if/else
      1. Exit Status and Return
        1. Return
      2. Combinations of Exit Statuses
      3. Condition Tests
        1. String comparisons
        2. About C Compilers
        3. File Attribute Checking
      4. Integer Conditionals
    2. for
    3. case
    4. select
    5. while and until
  8. 6. Command-line Options and Typed Variables
    1. Command-line Options
      1. shift
      2. Options with Arguments
      3. getopts
        1. More About C Compilers
    2. Integer Variables and Arithmetic
      1. Arithmetic Conditionals
      2. Arithmetic Variables and Assignment
    3. Arrays
      1. typeset
      2. Local Variables in Functions
      3. String Formatting Options
      4. Type and Attribute Options
      5. Function Options
  9. 7. Input/Output and Command-line Processing
    1. I/O Redirectors
      1. Here-documents
      2. File Descriptors
    2. String I/O
      1. print
        1. print escape sequences
        2. Options to print
      2. read
        1. Reading lines from files
        2. I/O Redirection and multiple commands
        3. Code blocks
        4. Reading User Input
        5. Options to read
    3. Command-line Processing
      1. Quoting
      2. eval
        1. The C Compiler as Pipeline
  10. 8. Process Handling
    1. Process IDs and Job Numbers
    2. Job Control
      1. Foreground and Background
      2. Suspending a Job
    3. Signals
      1. Control-key Signals
      2. kill
      3. ps
        1. System V
        2. BSD
    4. trap
      1. Traps and Functions
      2. Process ID Variables and Temporary Files
      3. Ignoring Signals
      4. Resetting Traps
    5. Coroutines
      1. wait
      2. Advantages and Disadvantages of Coroutines
      3. Parallelization
      4. Coroutines with Two-way Pipes
      5. Two-way Pipes Versus Standard Pipes
    6. Subshells
      1. Subshell Inheritance
      2. Nested Subshells
  11. 9. Debugging Shell Programs
    1. Basic Debugging Aids
      1. Set Options
      2. Fake Signals
        1. EXIT
        2. ERR
        3. DEBUG
    2. A Korn Shell Debugger
      1. Structure of the Debugger
        1. The driver script
        2. exec
      2. The Preamble
      3. Debugger Functions
        1. Commands
        2. Stepping
        3. Breakpoints
        4. Break conditions
        5. Execution tracing
        6. Limitations
      4. Sample kshdb Session
      5. Exercises
  12. 10. Korn Shell Administration
    1. Installing the Korn Shell as the Standard Shell
    2. Environment Customization
      1. umask
      2. ulimit
      3. Types of Global Customization
    3. System Security Features
      1. Restricted Shell
      2. A System Break-in Scenario
      3. Tracked Aliases
      4. Privileged Mode
  13. A. Related Shells
    1. The Bourne Shell
    2. The IEEE 1003.2 POSIX Shell Standard
    3. wksh
    4. pdksh
    5. bash
    6. Workalikes on PC Platforms
    7. The Future of the Korn Shell
  14. B. Reference Lists
    1. Invocation Options
    2. Built-in Commands and Keywords
    3. Built-in Shell Variables
    4. Test Operators
    5. Options
    6. Typeset Options
    7. Emacs Mode Commands
    8. Vi Control Mode Commands
  15. C. Obtaining Sample Programs
    1. FTP
    2. FTPMAIL
    3. BITFTP
    4. UUCP
  16. Index
  17. About the Author
  18. Colophon
  19. Copyright

Product information

  • Title: Learning the Korn Shell
  • Author(s): Bill Rosenblatt
  • Release date: January 1993
  • Publisher(s): O'Reilly Media, Inc.
  • ISBN: 9781565920545

You might also like

book

Wicked Cool Shell Scripts

by Dave Taylor

Fun and functional Linux, Mac OS X and UNIX shell scripts The UNIX shell is the …

book

Korn Shell Programming by Example

by Dennis O'Brien

Korn Shell Programming by Example is a straight-forward, nuts and bolts book that will become a …

audiobook

The China Dream

by Jonathan Krane

China GDP has grown from $300 per capita to more than $10,000 in the past thirty …

book

bash shell脚本编程经典实例 (第2版)

by Carl Albing, JP Vossen

对于系统管理员、程序员和最终用户而言,shell命令或精心设计的shell脚本不仅能节省时间和精力,还可以提升各种常见任务的一致性和可重复性。作为一款流行的Unix shell,bash让你能够利用和自定义Unix或Linux系统的任意功能。 本书将全面讲述bash,内容适用于所有Unix和Linux用户,无论新人还是老手(包括熟练的Windows用户和管理员)。书中提供了300多个bash实例,每个实例均包含一个或多个示例脚本,能够帮你解决各种各样的问题。你将学到如何处理输入/输出、文件操作、程序执行、管理任务以及许多其他挑战。 本书实例包括: 标准输出和输入以及执行命令 shell变量、shell逻辑和算术 中级shell工具和高级脚本编写 使用find、locate和slocate查找文件 处理日期和时间 为各种最终用户任务创建shell脚本 处理涉及解析操作的任务 编写安全的shell脚本 配置和自定义bash