[ This document consists of the text of the Preface of Using csh & tcsh, by Paul DuBois. Copyright (c) 1995 O'Reilly and Associates, Inc. All rights reserved. Permission is granted to copy this document for personal use only. This copyright notice must be retained in all copies. ]
A shell is a command interpreter. You type commands into a shell, and the shell passes them to the computer for execution. UNIX systems usually provide several shell choices. This handbook focuses on two of the shells: C shell (csh) and an enhanced C shell (tcsh).
C shell (csh), a popular command interpreter that has its origins in Berkeley UNIX, is particularly suited for interactive use. It offers many features, including an ability to recall and modify previous commands, a facility for creating command shortcuts, shorthand notation for pathnames to home directories, and job control.
tcsh, an enhanced version of csh, is almost entirely upward compatible with csh, so whatever you know about the C shell you can apply immediately to tcsh. But tcsh goes beyond csh, adding capabilities like a general purpose command line editor, spelling correction, and programmable command, file, and user name completion.
Shells other than csh and tcsh may be available on your system. The two most significant examples are the Bourne shell (sh) and the Korn shell (ksh). The Bourne shell is the oldest of the currently popular shells and is the most widely available. The Korn shell was developed at AT&T and is most prevalent on System V-based UNIX systems. Both shells are fully documented elsewhere, so we won't deal with them here.
This handbook is designed to help you use csh or tcsh more effectively. By demonstrating what these shells can do for you, and illustrating techniques for using their features, the handbook will show you how to get your work done more quickly and easily. You can increase your effectiveness on a number of fronts, ranging from learning how to repeat the previous command without typing the whole thing again, to learning how to use filename patterns, to using the shell startup files to make your working environment more pleasant and productive.
This handbook has two particular emphases:
This handbook can be used by anyone at any level of proficiency with csh or tcsh. It should be helpful in the following circumstances:
This handbook is divided into three parts. Part I, Learning the Basics, is designed to get you off the ground by providing a basic introduction to the shell and a broad survey that shows how to use the shell's more advanced features to accomplish many different kinds of tasks.
Part II, Becoming More Efficient, provides a more topical approach to the shell's capabilities. The chapters in Part II focus on particular aspects of the shell. You'll find these chapters useful when you want more information about features of the shell that are demonstrated in Part I.
Part III contains the appendixes, which provide information about obtaining and installing tcsh, a quick reference to those shell capabilities discussed in this handbook, and pointers to other documentation relating to csh and tcsh.
Chapter 1, Introduction, discusses the purpose of the shell and describes how to change your login shell to one of those discussed in this handbook.
Chapter 2, A Shell Primer, provides a summary of introductory essentials. If you already know something about running commands, you can skim this chapter as a review or skip it.
Chapter 3, Using the Shell Effectively, is an overview of many of the facilities that the shell provides to help you work more efficiently--easy, practical ways to get more out of the command line. Often, even experienced users are not aware of all of these features. This chapter gives you a glimpse of the kinds of techniques that are covered in detail in the rest of the book.
Chapter 4, The Shell Startup Files, describes ~/.cshrc and ~/.login, the files that the shell uses to initialize your working environment. This chapter also provides guidelines for modifying the startup files to suit your preferences.
Chapter 5, Setting Up Your Terminal, discusses how to find out what your terminal's special characters are (e.g., for backspacing) and how to change them if you don't like the default settings.
Chapter 6, Using Your Command History, discusses how to type less by using your command history.
Chapter 7, The tcsh Command-Line Editor, describes the facilities offered by the editor which enable you to edit commands interactively.
Chapter 8, Using Aliases To Create Command Shortcuts, discusses how to type less by using the shell's alias mechanism to create command shortcuts.
Chapter 9, File-Naming Shortcuts, describes ways in which the shell can supply filename arguments for you so that you don't have to type them all out yourself.
Chapter 10, Filename and Programmed Completion, describes how to use the shell for completing filenames after you type just the leading prefix. It also discusses how tcsh can complete other types of words besides filenames and how to set up programmed completions.
Chapter 11, Quoting and Special Characters, describes the shell's quoting rules. By following these rules, you can type any characters in a command line, even special ones, without having them misinterpreted.
Chapter 12, Using Commands To Generate Arguments, discusses command substitution, a facility that lets you construct pieces of a command line from the output of other commands.
Chapter 13, Navigating the File System, describes how to move around in the file system efficiently.
Chapter 14, Keeping Track of Where You Are, describes how to stay informed about your current location in the file system.
Chapter 15, Job Control, shows how to suspend, resume, and kill jobs; switch between jobs; and move jobs between the foreground and background.
Appendix A, Obtaining and Installing tcsh, describes how to make tcsh available on your system if you don't have the current version.
Appendix B, csh and tcsh Quick Reference, is a summary of those features and capabilities of csh and tcsh described in this handbook.
Appendix C, Other Sources of Information, contains pointers to other documentation. The most important of these references is the tcsh manual page. It's available in several forms, one of which can be navigated via hypertext links with a World Wide Web browser.
First, you should read Chapter 1. If necessary, change your login shell to csh or tcsh, using the instructions there.
If you're a beginner, unfamiliar with the shell, or just want to review the basics of executing simple commands, you should proceed to Chapter 2. If you're also having trouble figuring out how to do things like getting your terminal to backspace correctly, you may find it helpful to read Chapter 5.
If you already know something about the shell, you can skip the primer and proceed to Chapter 3. This chapter is designed to "jump start" you into better use of the shell by presenting lots of shortcuts that save you time and effort. You'll quickly become a more fluent command-line user by applying the information you find here.
For a more systematic and topical approach to the shell's capabilities, look at the chapters in Part II. They explain in greater detail the features of the shell that were briefly demonstrated in Chapter 3.
Finally, use the index. The shell's features interrelate, so you'll often find that a particular capability can be applied in many different contexts, and most likely will be discussed in several places.
Certain special characters on your keyboard are represented in the text in uppercase Constant Width, (e.g., TAB for the "tab" key). Other special characters are RETURN (sometimes labeled ENTER), ESC (sometimes labeled ESCAPE), DEL (sometimes labeled DELETE or RUBOUT), and BACKSPACE (which is the same as CTRL-H). Control characters, which you enter by holding down the CTRL (or CTL, or CONTROL) key and typing another key, are represented as CTRL-X, where X is some letter. (You might need the SHIFT key for non-alphabetic characters. For instance, if @ is on the same key as 2, you might have to hold down SHIFT to type CTRL-@.)
This book uses the following typographical conventions:
Used for UNIX commands, filenames, and variables.
Used in examples to show the contents of files or the output from commands. Constant Width is also used to indicate commands you type.
Used in examples to show interaction between you and the shell. The text that you type is shown in Constant Bold. For example:
% chsh Run the change-shell command Old shell: /bin/csh chsh displays your current shell New shell: /bin/tcsh Type in the shell you want to use instead
Used in examples to represent dummy parameters that should be replaced with an actual value.
Used to show the position of the cursor on a command line. For example, the cursor is positioned on the asterisk in the following command:
% sed -e 's/^ [*]//' datafile
Used in examples to show where you need to type a special character. In the following example, you type a CTRL-V and a TAB between the quotes:
% grep "[CTRL-V][TAB]" myfile
If you have comments on this book, suggestions for improvement, or corrections, please contact me by sending electronic mail to email@example.com.
My thanks to Partha S. Banerjee, Scott Bolte, Paul Placeway, Dave Schweisguth, Tim P. Starrin, Kimmo Suominen, Paul A. Vixie, and Christos Zoulas for reviewing the manuscript. Reviewer comments materially improved the content of this handbook. Tim Starrin suggested the section on read-only shell variables and provided the text on which it was based.
The members of the tcsh developer's mailing list provided assistance by discussing and clarifying several issues that I found confusing while writing. Dave Schweisguth was especially helpful in this regard; as the main force behind the current version of the tcsh manual page, he's familiar with the difficulties of trying to explain tcsh's features clearly.
Mary Kay Sherer cast her skeptical eye over my sometimes dubious prose, ferreting out and correcting many paraverbal constructions.
Adrian Nye served as general editor, but more than that, Adrian originated the idea for the book, then provided the guidance and encouragement that made it a reality. My thanks also to other O'Reilly staff, including Len Muellner, Norm Walsh, Sheryl Avruch, Kismet McDonough, Seth Maislin, Kiersten Nauman, Juliette Muellner, and Chris Reilley.
Finally, I appreciate the willingness of my wife, Karen, to accommodate the writing of another book, and for providing the occasional necessary reminder to let the keyboard cool off for a while. She also assisted the writing process by discussing with me the structure, approach, and content of the book. These thinking-out-loud sessions were invaluable in shaping Using csh & tcsh into its present form.