The UNIX™ C Shell Field Guide

Gail C. Anderson, Paul L. Anderson

Publisher: Prentice Hall, 1986, 374 pages

ISBN: 0-13-937468-X

Keywords: Programming

Last modified: March 7, 2022, 2:38 p.m.

In this timely new book, the authors present an in-depth study of the C shell as a command interpreter and the gateway to other programs and utilities running under UNIX. They discuss the C shell as it runs under UNIX 4.2BSD and 4.3BSD. In addition, they detail the differences found in versions running under UNIX System V, System III, XENIX, and Version 7.

As a guide to this powerful interface, this book:

  • shows you how to use the C shell effectively
  • explains its practical features
  • offers guidelines to using the C shell based on the authors' experience

Among its special features, the book:

  • offers situations typical to the software developer
  • presents the C shell's basic command forms, power, command shorthand, history, and alias mechanisms
  • shows how to customize the C shell to accommodate terminal types, working habits, login and logout procedures, and custom commands
  • includes diagrams to show how the C shell and UNIX execute commands
  • contains a separate chapter of 10 practical, ready-to-run C shell mscripts
  • contains a Key Point Summary, a Hints and Cautions section and a Putting It All Together section for most chapters

Of special interest are Appendix E, a collection of C shell summary tables, and Appendix G, a guide to using the C shell under XENIX.

  • Common UNIX Commands
  1. Introducing the C Shell
    1. What is the C Shell?
    2. What Are the C Shell's Functions?
    3. How Do You Use the C Shell?
      • Interactive Features
      • Customization
      • Programming
    4. Typical Examples Does the C Shell Run On?
    5. Why the C Shell?
  2. Climbing into Your Shell: A Tour of the C Shell
    1. Getting In: Login and Setup Files
      • Logging In to UNIX
      • Setting Up Your Terminal
      • The C Shell's Special Files
      • The .login Setup File
    2. Shorthand with the C Shell: History and Aliases
      • History List
      • Aliases
      • The .cshrc Setup File
    3. Making Things Happen: Issuing Commands
      • The UNIX File System
      • Simple Commands
      • Input and Output Redirection
      • Connecting Commands with Pipes
      • Command Groups
      • Background Commands
      • File Expansion Characters
    4. Taking the Load Off Your Fingers: Shell Variables and Command Substitution
      • Shell Variables
      • Command Substitution
    5. A First Step Toward Automation: A Simple C Shell Script
      • The ppd (Prepend) Script: First Version
    6. Giving Information and Getting Results: Input and Output
      • Output
      • Input
    7. Decision Time: Selective Execution
      • if Statements
      • if-else Statements
    8. Smarter C Shell Programs: Checking for Errors
      • The ppd (prepend) Script: Second Version
    9. A Rose by Any Other Name: Effective Use of Aliases
    10. Getting Out: Logout
      • The .logout Special File
      • A Final goodbye
  3. Basic Commands
    1. What's in a Name? Directory and File Names
    2. Taking Charge: Issuing Commands
      • Single Commands
      • Multiple Commands
      • Command Groups
    3. Sending Results Where You Want Them: Output Redirection
      • Standard Output
      • Appending Output
      • Diagnostic Output
      • Separating Standard Output and Diagnostic Output
      • Safer Redirection and Appending
    4. Getting the Input You Need: Input Redirection
    5. Making the Right Connections: Pipes
    6. Only on Condition: Conditional Command Execution
    7. Putting It All Together
    8. Hints and Cautions
    9. Key Point Summary
  4. Command Shorthand
    1. Playing Your Wildcard: Filename Expansion
    2. Mark My Words: C Shell Variables
      • Defining Shell Variables
      • Using C Shell Variables
      • Accessing Pathname Variables
    3. Building Strings from Command Output: Command Substitution
    4. Don't Lose Anything in Translation: Quoting
      • Escaping Characters
      • Escaping Strings
      • Quoting Variables: :x and :q
    5. Putting It All Together
    6. Key Point Summary
  5. Job Control
    1. In the Main Ring: Foreground Jobs
    2. Over at the Sideshow: Background Jobs
      • Setting CPU Limits
    3. Managing Your Resources: Job Control
      • Terminating Processes
      • Detached Jobs
      • Full Job Control
      • Terminal Input for Background Jobs
      • Terminal Output for Background Jobs
      • Notification of Changes in Background Jobs
      • Implied Directory Changes
    4. Hints and Cautions
    5. Key Point Summary
  6. History and Alias Mechanisms
    1. The Past Is Always Present: The History List
      • Displaying the History List
      • Choosing the Size of the History List
      • History Repeats Itself: Reissuing Past Commands
      • Executing Past Commands by Matching Strings
      • Changing the Course of History: Building New Commands
      • Editing Previous Commands
      • Look Before You Leasp
      • Pathname Qualifiers
      • Metacharacters in Pattern Searching
      • Saving the History List
      • Common Mistakes with the History List
      • History Command Summary
    2. Using Your Own Pet Names: Aliases
      • Alias Command Format
      • Referencing Other Aliases
      • Arguments in Aliases
      • Aliases Come First
      • Alias Examples
      • When Not to Use Aliases
      • Common Mistakes with Aliases
    3. Putting It All Together
    4. Key Point Summary
  7. C Shell Programming
    1. Why Improve When You Can Have a Script? C Shell Scripts
    2. Including Your Own Thoughts: Comment Lines
    3. Your Program Talks: echo
    4. Flexing Your Program's Muscles: Using Arguments
    5. A Quick Return: exit
    6. Speak and Ye Shall Be Heard: Reporting Diagnostic Output
    7. In the Valley of Decision: Conditional Statements
    8. Express Yourself: Expressions and Operators
      • Assignment Operators
      • Arithmetic, Bitwise, and Logical Operators
      • Comparison Operators
      • Operator Precedence
    9. Sizing Up a File: File Inquiry Operators
    10. Over and Over and Over Again: foreach
    11. Around and Around We Go: Conditional Loops and Shifting
      • While Construct
      • Shift Statement
    12. Selecting Only the Best: switch
    13. Getting Off the Beaten Path: break, continue, goto
      • break
      • continue
      • goto
    14. Talk to Your Script: Reading Data from the Terminal
      • Reading a Line with $< (BSD)
      • Reading a Line with gets
    15. A Commanding Script: Making a Script into A Command
    16. Hints and Cautions
    17. Key Point Summary
  8. Advanced Programming Techniques
    1. A Time for Ad-Libbing: Looping at the Terminal
    2. Staking Out Your Own Territory: Using /tmp
      • Creating Temporary Files
      • The /tmp Directory
    3. Preparing for the Unexpected: Interrupt Handling
      • Interrupting Scripts
      • Interrupting Shared Scripts
    4. Using Canned Responses: Here Documents
    5. Calling Yourself To Task: Recursive Scripts
    6. Easy Quoting: noglob
    7. Correcting the Errors of Your Ways: Debugging C Shell Scripts
      • Debugging with -n (Syntax Checking)
      • Debugging with -v (Verbose)
      • Debugging with -x (Echo)
    8. As Time Goes By: Timing Your Scripts
      • The time Command
      • Optimizing Shell Scripts: An Example
    9. Making the Best of It: C Shell Script Guidelines
      • Don't Reinvent the Wheel
      • Why Write a Script?
      • A Framework for Your Scripts
      • Moving Towards Efficiency
      • Combining Commands in a Pipeline
      • Fast Shell Startup
    10. Hints and Cautions
    11. Key Point Summary
  9. Customizing the C Shell
    1. Your Wish Is My Command: A Sample Customization Session
      • The .cshrc File
      • The .login File
      • The .logout File
    2. Customization with Predefined Variables
      • path
      • cdpath
      • home
      • shell
      • mail
      • history
      • histchars
      • savehist
      • prompt
      • ignoreeof
      • noclobber
      • time
      • Special Files Revisited
      • Displaying Your Shell Variables: Using set
    3. Customization with Environmental Variables
      • TERM
      • HOME
      • PATH
      • LOGNAME or USER
      • SHELL
      • MAIL
      • EXINIT
      • TERMCAP
      • Special Files Revisited
      • Displaying Your Environmental Variables: Using env
    4. Customization with Built-in Commands
      • umask
      • exit
      • source
      • exec
      • limit
    5. Making It Personal: Creating Your Own Special Files
      • Using source to Change the Special Files
      • When One .cshrc File Isn't Enough: A New Environment
      • Special Files Revisited: A Last Time
    6. Putting It All Together
    7. Hints and Cautions
    8. Key Point Summary
  10. Inside the C Shell
    1. The C Shell's Job: Parsing Order
      • Step 1: History Substitution
      • Step 2: Finding Words
      • Step 3: Updating the History List
      • Step 4: Parsing the Sequence of Words
      • Step 5: Execute Each Command
    2. The Family Tree: Parent and Child Processes
      • Process Creation (fork)
      • Executing a Command (exec)
      • Waiting for the Command to Finish (wait)
      • The Command Finishes (exit)
    3. The Child Shell as Traffic Policeman: Redirection Revisited
      • Input/Output Redirection
      • Standard and Diagnostic Redirection
      • Appending Standard Output
      • Redirection First
    4. The Case of the Common Ancestor: Pipes Revisited
    5. Meanwhile, In the Side Rings: Background Execution Revisited
    6. Who's on First? Aliases and Built-in Commands
      • Built-in Versus UNIX Commands
      • The Order of Things
    7. Hand-Me-Downs: Creating Subshells
      • Command Groups
      • Command Substitution
    8. Starting Over: Executing New Shells
      • Executing Shell Scripts
      • Escaping to New Shells
      • Aliases and Shell Variables
      • Environment Variables
    9. Putting It All Together
    10. Hints and Cautions
    11. Key Point Summary
  11. Example C Shell Scripts
    1. While the Show Goes On: Compiling C Programs in the Background (ccpb)
    2. Quick and Easy Find: Locate a file (loc)
    3. A Simple Help Utility: Learning UNIX Commands (usage)
    4. Learning New Vocabulary: Language Tutor (tutor)
    5. Customizing a Standard XENIX Utility: Getting Files from a DOS Disk (dosget)
    6. Looking for Changes: Monitoring System Security (bd)
    7. A Friendly User Interface: Simple Menu Program (menu)
    8. The Search Is On: Pattern Searching Made Easy (search)
    9. Keeping It All Together: Which Command Do I Get Anyway? (which)
    10. All It's Stacked Up to Be: Directory Stacks (pushdpopddirs)
  1. Glossary
  2. Predefined C Shell Variables
  3. Built-in C Shell Commands
  4. C Programs for echo2, getch, and gets
    • Installation
  5. A Summary of the C Shell
    • Notation
    • Special Characters for Issuing Commands
    • Input/Output Redirection
    • Filename Expansion and Pattern Matching
    • Quoting
    • Special Characters That Must Be Escaped
    • Shell Variables
    • Variable Modifiers
    • History List Recall
    • Job Control (BSD only)
    • Operators
    • Assignment Operators
    • File Inquiry Operators
    • C Shell Programming
    • Special Files
  6. UNIX Database Files
    • /etc/passwd
    • /etc/group
    • /etc/ttytype
    • /etc/termcap
    • /etc/cshrc
  7. The C Shell Under XENIX
    • History List
    • Shell Environment Variables
    • Command Differences
    • Directory Stacks
    • Operators
    • Shell Scripts
    • Input from the Terminal
    • Job Control
    • Special Files

Reviews

The UNIX™ C Shell Field Guide

Reviewed by Roland Buresund

Very Good ******** (8 out of 10)

Last modified: May 21, 2007, 3:18 a.m.

A very good reference on the subject.

Comments

There are currently no comments

New Comment

required

required (not published)

optional

required

captcha

required