Learning the Korn Shell - This Nutshell Handbook 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.
Korn Shell Programming by Example - 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.
The New Kornshell Command and Programming Language - This second edition of the KornShell book is the specification of the revised KornShell language and a reference handbook for ksh, the program that implements the KornShell language.
The language has undergone major changes and additions since the first edition. The new features of the language have increased the scope of applications that are suitable for writing in ksh. In addition, command completion and a key binding mechanism have been added to this version of ksh.
This book also contains a Tutorial that describes both of the functions of ksh: as an interactive command language, and as a programming language. It contains numerous examples illustrating the features of ksh, and many chapters have exercises. It also contains a Quick Reference summary of the KornShell language, including page references to the book. The format of this second edition is similar to that of the first edition. This makes it easy for readers familiar with the first edition to use this book. In addition to describing the new features of the language, many reader suggestions have been incorporated.
This book is intended both for new users with little computer or shell experience, and for experienced computer users who are familiar with ksh and/or other shells. For new users, it has considerable tutorial material. For all users, it is a comprehensive reference handbook.
What is the KornShell Language? The KornShell language was designed and developed by David G. Korn at AT&T Bell Laboratories. It is an interactive command language that provides access to the UNIX system and to many other systems, on the many different computers and workstations on which it is implemented. The KornShell language is also a complete, powerful, high-level programming language for writing applications, often more easily and quickly than with other high-level languages. This makes it especially suitable for prototyping. There are two other widely used shells, the Bourne shell developed by Steven Bourne at AT&T Bell Laboratories, and the C shell developed by Bill Joy at the University of California. ksh has the best features of both, plus many new features of its own. Thus ksh can do much to enhance your productivity and the quality of your work, both in interacting with the system, and in programming. ksh programs are easier to write, and are more concise and readable than programs written in a lower level language such as C.
The new version of ksh has the functionality of other scripting languages such as awk, icon, perl, rexx, and tcl. For this and many other reasons, ksh is a much better scripting language than any of the other popular shells. The code size for ksh is larger than the Bourne shell or C shell programs. The revised version is even larger.
In spite of its increased size, ksh provides better performance. You can write programs to run faster with ksh than with either the Bourne shell or the C shell, sometimes an order of magnitude faster. ksh has evolved and matured with extensive user feedback. It has been used by many thousands of people at AT&T since 1982, and at many other companies and universities. A survey conducted at one of the largest AT&T Bell Laboratories computer centers showed that 80% of their customers, both programmers and non-programmers, use ksh. ksh is compatible with the Bourne shell. Virtually all programs written for the Bourne shell run with ksh. If you are familiar with the Bourne shell, you can use ksh immediately, without retraining. The new version of ksh is compatible with earlier versions of ksh. ksh is readily available. It is sold (source and binary) by AT&T and Novell, and by other companies under license from AT&T both in the USA and abroad. It has been purchased by dozens of major corporations, and by many individuals for use on home computers. ksh is extensible.
The KornShell language uses the same syntax for built-in commands as for non built-in commands. Therefore, system developers can add new commands "transparently" to the KornShell language; that is, with minimum effort and with no differences visible to users other than faster execution. On systems with dynamic linking, it is possible to add new built-in commands at run time. Novell has extended the new version of ksh to enable X-windows programming for their desktop ksh product, dtksh. dtksh is a standard part of CDE, the Common Desktop Environment defined by COSE (Common Operating System Environment), supported by most major UNIX system hardware vendors.
ksh is intended to conform to the Shell Language Standard developed by the IEEE POSIX 1003.2 Shell and Utilities Language Committee. At the time the manuscript of this book was sent to the publisher, 1992 was the current version of the POSIX Standard. To the best of our knowledge, the description of ksh in this book is consistent with the 1992 standard.
Organization of this Book
Part I, Introduction, tells what a shell is and lists the benefits of the KornShell language. It tells how to obtain ksh and explains about different versions of ksh. It also specifies the notation used in this book.
Part II, Tutorial, has chapters on Operating System Concepts and on the use of the KornShell language as a Command Language and a Programming Language. The Operating System Concepts chapter covers files, processes, strings and patterns that provides background information to help you understand the KornShell language. You do not have to understand everything in it to read the remaining chapters.
The Command Language chapter is intended as a guide through the language by giving step-by-step instructions for some of the typical uses of ksh. It is not intended to explain in detail all of the features of ksh, or all of the possible uses of the features that are discussed in this chapter. All of the features of the KornShell language are covered in detail elsewhere in this book.
The Programming Language chapter is intended as an introduction to the features of the KornShell that are used primarily for writing scripts or applications in the shell language.
Part II, Tutorial, also has a chapter on Customizing Your Environment, which describes how to set up your profile and environment files. It also suggests ways for optimizing the performance of shell scripts.
Part III, The Built-In Editors, is a detailed manual for the emacs and vi built-in line editors that are part of ksh. Each of these is a subset of the corresponding editor. A major benefit of using ksh is that you can use emacs or vi directives to edit your current command line, or to edit and reenter previous commands.
Part IV, Programming Language, is both a specification for the KornShell language and a detailed guide to using it. It contains chapters on Syntax, Command Processing, Compound Commands, Parameters, Built-in Commands, and Invocation and Environment. It also contains a chapter, Other Commands, which documents programs that are not part of ksh, but which are used in the examples in this book and may prove useful to many users. UNIX systems and many other systems have these programs.
Part V, Application Programming, has a chapter on Shell Functions and Programs, with several functions and programs written in the KornShell language. They are included primarily for illustrative purposes. However, you may find some of these functions and/or programs useful.
It also has the chapter, A Complete Application, with an example of how to use ksh as a high-level programming language, to program an application. The example that we use is a slightly modified version of the MH (Message Handling) system.
Part VI, Appendix, contains a Glossary. It also has a Quick Reference, with the formats, options, and page references for all ksh built-in, non-built-in, and editor commands, parameters, and other details.
The Portability chapter contains information to help you write portable scripts. There are sections listing features of ksh not in the Bourne Shell, features of ksh not in the System V Release 4 Shell, and features of ksh not in the POSIX shell. This chapter also lists ksh features that are in the POSIX shell but not in the System V Release 4 shell. In addition it discusses incompatibilities between ksh and the System V Release 4 Bourne Shell, and how ksh meets the POSIX requirements. A summary of all the new features in the 12/28/93 version of ksh, obsolescent features, and possible extensions to ksh are presented. Because of the large number of csh users migrating to ksh, we have included a section of helpful hints for making this task easier.
The Character Set chapter defines the character representation for ASCII encoding, and the character classes that each character belongs to in the C and POSIX locales.
There is also a detailed Index. The outside back cover has page references to all commands and parameters, and a brief summary of key emacs and vi directives.
This is a Second Edition of the best-selling guide to the KornShell command and programming language by the original inventors of the language. It provides a specification for the KornShell language, tutorial material for those new to ksh (the program that implements the KornShell language), and a comprehensive reference for all ksh users. Covers major new additions to the KornShell language ksh93 (including command completion and a key binding mechanism); provides tutorials for both of the functions of ksh (as an interactive command language, and as a programming language); contains numerous examples illustrating the features of ksh; and features a Quick Reference summary of the KornShell language with page references to the book. For both new users with little shell experience, and for experienced computer users who are familiar with ksh and/or other shells.