HAPPY BOOKSGIVING
Use code BOOKSGIVING during checkout to save 40%-55% on books and eBooks. Shop now.
Register your product to gain access to bonus material or receive a coupon.
If you are a Unix or Linux Shell programmer, this book will provide you with the practical advice and technical tips you will need in order to become proficient in all aspects of the Korn Shell and enhance your programming skills. From basic introductory concepts through to advanced programming techniques, you will learn how to:
Illustrated throughout with expansive sample programs and easy-to-apply examples, plus complete ready-to-run scripts, this book will prove an indispensable guide and technical reference for the Korn Shell.
"This is the best Korn Shell book I've seen. I presently have at least five different books on Shell programming in Unix. I actually was able to read this book cover to cover AND am able to use this as a reference...I found this book to be very complete."
John A. Siegel, Solution Engineer, Pershing, a Division of Donaldson Lufkin and Jenrette
Variables and Parameters in the Korn Shell
Preface.
Korn Shell 93: The Latest Version.
Acknowledgements.
Miscellaneous.
Conventions.
Cource Code Listing.
Licensing Agreement.
1. Introduction.
Major Features.
Where to Get the Korn Shell.
Which Version Do You Have?
Logging In.
Changing the Login Shell.
Invoking the Korn Shell Separately.
Using the Korn Shell in Scripts.
Simple Script.
Process Execution.
Multiple Commands.
Continuing Commands.
Background Jobs.
Pipes Conditional Execution.
Grouping Commands.
Input/Output Redirection.
Redirecting Standard Output.
The noclobber Option.
Redirecting Standard Input.
File Descriptors.
Redirecting Standard Error.
More with File Descriptors.
Here Documents.
Here Documents and File Descriptors.
Discarding Standard Output.
File Name Substitution.
The * Character.
The ? Character.
The [ ] Characters.
The ! Character.
Matching Files.
Complex Patterns. *(pattern).
?( pattern).
+( pattern).
@(pattern).
!( pattern).
More Complex Patterns.
Disabling File Name Substitution.
Command Substitution.
Bourne Shell Compatibility.
Directing File Input.
Arithmetic Operations.
Tilde Substitution.
Variables.
Accessing Variable Values.
Variable Attributes.
Lowercase (ål) and Uppercase (åu). Attributes.
Readonly (år) Attribute.
Integer (åi) Attribute 50.
Korn Shell 93: The Latest Version
The Korn Shell User and Programming Manual is designed to be a reference and learning tool for a range of users - from the novice with some experience to the pro who is familiar with both the Bourne and C shells. It contains complete technical information, as well as hands-on examples and complete programs to help guide you and illustrate all the features of the Korn shell. This edition of the book has been updated to cover Korn Shell 93, the latest version of the Korn shell. This book also assumes that you are familiar with the basic Unix commands, and understand file system concepts. You should also be able to login to a system, and enter basic commands.
If you are an experienced user, you may want to skip Chapter 1 and the first half of Chapter 2. The first seven chapters deal primarily with interactive use, while Chapter 8 and 9 cover the programming concepts.
The goal of this book to teach you the Korn shell, and this is done by walking you through examples. So by the time you are finished reading the book, you'll be comfortable with it, and writing your own Korn shell scripts.
But don't just read the book. The best way for you to learn about the Korn shell is to type in the examples yourself. Then do some experimentation on your own by either modifying the examples or coming up with your own commands.
Chapter 1 contains an overview of the major features in the Korn shell. It covers where to get it, how your login shell is configured, and setting up the Korn shell to co-exist with other shells while you are on the learning curve. It also includes brief descriptions of other related shells, including the Born Again shell (bash), Mortice Kern shell (ksh) for PC/Windows, and the public domain Korn shell (pdksh) for Linux.
Chapter 2 covers the Korn shell basics: how commands can work together to do other things, and some basic shortcuts to improve productivity, and Korn shell I/O. You'll also be introduced to file name, command, and tilde substitution: important concepts that are the basis of much of the Korn shell.
Chapter 3 teaches you about Korn shell variables, variable attributes, and parameters. You'll learn about all the different types of variable expansion, including the substring features. Array variables and quoting are also discussed in detail.
Chapter 4 discusses the Korn shell command history mechanism and vi and emacs in-line editors. Here you will learn how to call up previous commands and manipulate them.
Chapter 5 shows you how to manage and manipulate multiple processes using the job control mechanism, a feature almost directly copied from the C shell.
In Chapter 6, you will learn how to perform arithmetic with the Korn shell. It contains sections on multi-base arithmetic, declaring integer- type variables, and random numbers, along with examples for each type of arithmetic operator.
Chapter 7 will show you how to set up your own customized environment: from setting up the prompt how you like it, to configuring your personal email. Korn shell options, environment variables, aliases, the .profile
file, and subshells are also covered.
In Chapter 8, you are taught how to write programs using the many Korn shell commands and features. Executing and debugging scripts, input/output commands, positional parameters, flow control commands such as case, for, if, select, while, and until are also discussed. Step-by-step examples are included, and complete usable scripts are built from the bottom up. For those experienced Unix programmers, important differences between the Korn and Bourne shells are discussed, and something else new to Unix shell programming - performance. You'll learn a few tricks that can speed up execution of your Korn shell scripts.
Chapter 9 covers miscellaneous commands, such as readonly, ulimit, whence, and Korn shell functions.
Appendix A and B include a sample ready-to-use profile and environment file.
Appendix C contains the Korn shell versions of a number of C shell commands and functions.
Appendix D contains the source code listing for a number of handy ready-to-run Korn shell scripts, including an interactive calendar program.
Appendix E contains the Korn shell man pages.
Appendix F contains information about pdksh
, the public domain version of the Korn shell for Linux.
Appendix G contains the Pdksh quick reference guide, and Appendix H contains the Pdksh man page.
This edition is based on the latest edition of the Korn shell. There have been a number of new features and enhancements added to Korn Shell 93 including:
Thanks to David Korn for developing the Korn shell, Steven Bourne for the Bourne shell, and Bill Joy for the C shell. Other thanks to Mike Veach and Pat Sullivan for contributing to the development of the Korn shell, and Mark Horton, Bill Joy (again), and Richard Stallman for developing the vi and emacs editors which were used in the development of the Korn shell.
Special thanks to Peter Collinson, Cynthia Duquette, Ian Jones, Peter Kettle, Heather Prenatt, the ASP staff, Aspen Technologies, O'Reilly & Associates (who reviewed the initial draft of this book before publishing their own Korn shell book!), James Lamm, Darian Edwards and others for reviewing drafts of this book.
MiscellaneousThe information and material has been tested and verified to the best of our ability. This does not mean that it is always 100% correct! Subtle differences and variations may exist between implementations and features may have changed. And of course there may even be bugs or mistakes! Please send us any comments or suggestions for future editions, along with information about your environment. Please visit our Web site for more information www.aw.com/cseng.
Source Code ListingIf you would like the source code listing to the Korn shell scripts listed in the appendices, please visit our web site at www.aw.com/cseng.
Licensing AgreementThis book comes with a CD software package. By opening this package you are agreeing to be bound by the license terms contained on the CD- ROM.