The first book that covers all three
UNIX shells plus
Awk,
Sed, and Grep!
Until now, if you wanted to learn UNIX shell
programming, you had to purchase three or four books, each
covering just some of what you need to know. Now, one book
is all you need: UNIX Shells by Example.
This is the first complete, step-by-step guide to using
all three of the most important UNIX shells: the C shell,
the Bourne shell, and the Korn shell; and the essential
UNIX shell programming utilities. Using easy-to-understand,
classroom-proven examples, it brings together all the
information shell programmers need.
You'll start with the basics: what a UNIX shell is, what
it does, and how it relates to other UNIX utilities and
UNIX processes. You'll be introduced to shell scripts: what
they do, and how to create and run them. There's detailed
coverage of the essential tools every shell programmer
should understand, including:
- Grep, Egrep and Fgrep.
- Sed, the Streamlined Editor.
- Awk, the UNIX pattern scanning, text filter and report
language.
Next, take a closer look at each of the three leading
UNIX shells: the C shell, the Bourne shell, and the Korn
shell. UNIX Shells by Example presents parallel coverage of
each shell, so it's easy to see how they compare and when
to use each.
Teachers and consultants will appreciate the Appendix
that includes a listing of syntax and examples of many
useful UNIX utilities, a comparison chart of all three
shells, a complete guide to proper quoting, and classroom
exercises for each topic.
The book's accompanying CD-ROM contains all example
programs, a library of additional source code, and a suite
of shellprogramming utilities for UNIX, Linux, DOS,
Windows, OS/2, and Amiga systems.
Whether you're a system administrator, application
developer or power user, UNIX Shells by Example is the most
convenient, cost-effective way to learn UNIX shell
programming.
Table of Contents
- Preface
- Acknowledgments
- Introduction to UNIX Shells
- Definition andFunction
- The Three Major Shells
- History of the Shell
- Uses of the Shell
- Responsibilities of the Shell
- System Startup and the Login Shell
- Parsing the Command Line
- Types of Commands
- Processes and the Shell
- Creating Process
- The Environment and Inheritance
- Ownership
- The File Creation Mask
- Changing Permissions with chmod
- Changing Ownership with the chown Command
- The Shell and Signals
- Executing Commands from Scripts
- Sample Scripts: Comparing Three Shells
- The C Shell Script
- The Bourne Shell Script
- The Korn Shell Script
- The UNIX Tool Box
- Regular Expressions
- Definition and Example
- Regular Expression Metacharacters
- Combining Regular Expression Metacharacters
- More Regular Expression Metacharacters
- The Grep Family
- The Grep Command
- The Meaning of Grep
- How Grep Works
- Grep and Exit Status
- Grep Examples with Regular Expressions
- Grep with Pipes
- Grep with Options
- Grep Review
- Egrep (Extended Grep)
- Egrep Examples
- Egrep Review
- Fixed Grep or Fast Grep
- The Streamlined Editor
- What Is Sed?
- How Does Sed Work?
- Addressing
- Commands and Options
- Error Messages and Exit Status
- Metacharacters
- Sed Examples
- Printing: The p Command
- Deleting: The d Command
- Substitution: The s Command
- Range of Selected Lines: The Comma
- Multiple Edits: The e Command
- Reading from Files: The r Command
- Writing to Files: The w Command
- Appending: The a Command
- Inserting: The i Command
- Next: The n Command
- Transform: The y Command
- Quit: The q Command
- Holding and Getting: The h and g Commands
- Holding and Exchanging: The h and x
- Commands
- Sed Scripting
- Sed Script Examples
- Sed Review
- The Awk Utility: Awk as a UNIX Tool
- What Is Awk?
- What Does Awk Stand for?
- Which Awk?
- Awk's Format
- Input from Files
- Input from Commands
- Formatting Output
- The print Function
- The OFMT Variable
- The printf Function
- Awk Commands from within a File
- Records and Fields
- Records
- Fields
- Field Separators
- Patterns and Actions
- Patterns
- Actions
- Regular Expressions
- The Match Operator
- Awk Commands in a Script File
- Review
- Simple Pattern Matching
- Simple Actions
- Regular Expressions in Pattern and Action
- Combinations
- Input Field Separators
- Awk Scripting
- The Awk Utility: Awk Programming Constructs
- Comparison Expressions
- Relational Operators
- Conditional Expressions
- Computation
- Compound Patterns
- Range Patterns
- A Data Validation Program
- Review
- Equality Testing
- Relational Operators
- Logical Operators
- Logical Not Operator
- Arithmetic Operators
- Range Operator
- Conditional Operator
- Assignment Operators
- The Awk Utility: Awk Programming
- Variables
- Numeric and String Constants
- User-Defined Variables
- BEGIN Patterns
- END Patterns
- Redirection and Pipes
- Output Redirection
- Input Redirection (Getline)
- Pipes
- Closing Files and Pipes
- Review
- Increment and Decrement Operators
- Built-In Variables
- BEGIN Patterns
- END Patterns
- Awk Script with Begin and End
- The printf Function
- Redirection and Pipes
- Opening and Closing a Pipe
- Conditional Statements
- If Statements
- if/else Statements
- if/else else if Statements
- Loops
- While Loop
- For Loop
- Loop Control
- Program Control Statements
- Next Statement
- Exit Statement
- Arrays
- Subscripts for Associative Arrays
- Processing Command Arguments: Nawk
- Awk Built-In Functions
- String Functions
- Built-In Arithmetic Functions
- Integer Function
- Random Number Generator
- User-Defined Functions (nawk)
- Review
- Odds and Ends
- Fixed Fields
- Bundling and Unbundling Files
- Multi-line Records
- Generating Form Letters