Home > Store

UNIX Shells by Example, 4th Edition

Register your product to gain access to bonus material or receive a coupon.

UNIX Shells by Example, 4th Edition


  • Sorry, this book is no longer in print.
Not for Sale



The million dollar UNIX shell programming classic! Now updated to include Linux!

° "Shell Programming Quick-Start" transforms readers into a productive shell programmers in only 15 pages!

° The ONLY shell programming book readers need--covers all four major UNIX and Linux shells PLUS awk/sed/grep and their gnu equivalents.

° The accompanying CD contains all of the example programs and data files covered in the book.


  • Copyright 2005
  • Dimensions: 7" x 9-1/4"
  • Pages: 1200
  • Edition: 4th
  • Book
  • ISBN-10: 0-13-147572-X
  • ISBN-13: 978-0-13-147572-4

The world’s #1 shell programming book—now fully updated for Linux and more!

UNIX Shells by Example is the world’s #1 shell programming book, from the world’s #1 shell programming instructor: Ellie Quigley. In UNIX Shells by Example, Fourth Edition, Quigley has thoroughly updated her classic and delivers the information today’s shell programmers need most—including comprehensive coverage of Linux shell programming with bash!

Drawing on 20 years’ experience as a shell programming instructor, Quigley guides you through every facet of programming all leading UNIX/Linux shells: bourne, bash, korn, C, and tcsh. Quigley illuminates each concept with up-to-date, classroom-tested code examples designed to help you jump-start your own projects. She also systematically introduces awk, sed, and grep for both UNIX and GNU/Linux . . . making this the only shell programming book you’ll ever need!

New in this edition:
  • Comprehensive coverage of Linux shell programming with bash
  • Shell Programming QuickStart: makes first-time shell programmers productive in just 15 pages
  • Complete, practical debugging chapter
  • Updated coverage of the latest UNIX and GNU/Linux versions of awk, sed, and grep
  • Shell programming for sysadmins: walks you through key UNIX and Linux system shell scripts
Completely updated:
  • Shell programming fundamentals: what shells are, what they do, how they work
  • Choosing the right shell for any application

Nearly 50,000 UNIX/Linux sysadmins, developers, and power users have used previous editions of UNIX Shells by Example to become expert shell programmers. With UNIX Shells by Example, Fourth Edition, you can, too—even if you’re completely new to shell programming. Then, once you’re an expert, you’ll turn to this book constantly as the best source for reliable answers, solutions, and code.

About the CD-ROM

Comprehensive shell programming code library: all source code and data files for this book’s hundreds of example programs.

Sample Content

Online Sample Chapter

UNIX Shell Programming QuickStart

Downloadable Sample Chapter

Download the Sample Chapter related to this title.

Table of Contents



1. Introduction to UNIX/Linux Shells.

    What Is UNIX? What Is Linux? A Little History.

    Definition and Function of a Shell.

    History of the Shell.

    System Startup and the Login Shell.

    Processes and the Shell.

    The Environment and Inheritance.

    Executing Commands from Scripts.

2. Shell Programming QuickStart.

    Taking a Peek at Shell Scripts.

    Sample Scripts: Comparing the Major Shells.

    The C and TC Shell Syntax and Constructs.

    The Bourne Shell Syntax and Constructs.

    The Korn Shell Constructs.

    The Bash Shell Constructs.

3. Regular Expressions and Pattern Matching.

    Regular Expressions.

    Combining Regular Expression Metacharacters.

4. The grep Family.

    The grep Command.

    grep Examples with Regular Expressions.

    grep with Options.

    grep with Pipes.

    egrep (Extended grep).

    fgrep (Fixed grep or Fast grep).

    Linux and GNU grep.

    GNU Basic grep (grep -G) with Regular Expressions.

    grep -E or egrep (GNU Extended grep).

    Fixed grep (grep -F and fgrep).

    Recursive grep (rgrep, grep -R).

    GNU grep with Options.

    grep with Options (UNIX and GNU).

    LAB 1: grep Exercise.

5. sed, the Streamlined Editor.

    What Is sed?

     Versions of sed.

    How Does sed Work?

    Regular Expressions.


    Commands and Options.

    Error Messages and Exit Status.


    sed Examples.

    sed Scripting.

    LAB 2: sed Exercise.

6. The awk Utility.

    What's awk? What's nawk? What's gawk?

    awk's Format.

    How awk Works.

    Formatting Output.

    awk Commands from Within a File.

    Records and Fields.

    Patterns and Actions.

    Regular Expressions.

    awk Commands in a Script File.


    LAB 3: awk Exercise.

    Comparison Expressions.


    LAB 4: awk Exercise.


    Redirection and Pipes.



    LAB 5: nawk Exercise.

    Conditional Statements.


    Program Control Statements.


    awk Built-In Functions.

    Built-In Arithmetic Functions.

    User-Defined Functions (nawk).


    LAB 6: nawk Exercise.

    Odds and Ends.

    LAB 7: nawk Exercise.

    awk Built-In Functions.

7. The Interactive Bourne Shell.


    The Environment.

    The Command Line.

    Shell Metacharacters (Wildcards).

    Filename Substitution.



    Command Substitution.

    An Introduction to Functions.

     Standard I/O and Redirection.


    The here document and Input.

8. Programming the Bourne Shell.


    Reading User Input.


    Positional Parameters and Command-Line Arguments.

    Conditional Constructs and Flow Control.

    Looping Commands.


    Trapping Signals.

    The Command Line.

    Shell Invocation Options.

    LAB 8: Bourne Shell--Getting Started.

    LAB 9: Metacharacters.

    LAB 10: Redirection.

    LAB 11: First Script.

    LAB 12: Command-Line Arguments.

    LAB 13: Getting User Input.

    LAB 14: Conditional Statements.

    LAB 15: Conditionals and File Testing.

    LAB 16: The case Statement.

    LAB 17: Loops.

    LAB 18: Functions.

9. The Interactive C and TC Shells.


    The Environment.

    The C/TC Shell Command Line.


    Manipulating the Directory Stack.

    Job Control.

    Shell Metacharacters.

    Filename Substitution.

    Redirection and Pipes.


    Command Substitution.


    New Features of the Interactive TC Shell.

    The TC Shell Command Line.

    TC Shell Command, Filename, and Variable Completion.

    TC Shell Spelling Correction.

    TC Shell Aliases.

    TC Shell Job Control.

    Printing the Values of Variables in the TC Shell.

    TC Shell Built-In Commands.

    Lab 19: The TC Shell--Getting Started.

    Lab 20: History.

    Lab 21: Shell Metacharacters.

    Lab 23: Variables and Arrays.

    Lab 22: Redirection.

10. Programming the C and TC Shells.


    Reading User Input.


    Debugging Scripts.

    Command-Line Arguments.

    Conditional Constructs and Flow Control.

    Looping Commands.

    Interrupt Handling.

    setuid Scripts.

    Storing Scripts.

    Built-In Commands.

    Lab 24: C/TC Shells--Getting Started.

    Lab 25: Shell Metacharacters.

    Lab 26: Redirection.

    Lab 27: First Script.

    Lab 28: Getting User Input.

    Lab 29: Command-Line Arguments.

    Lab 30: Conditionals and File Testing.

    Lab 31: The switch Statement.

    Lab 32: Loops.

11. The Interactive Korn Shell.


    The Environment.

    The Command Line.

    Commenting and Filename Expansion.


    Job Control.


    Filename Substitution (Wildcards).



    Command Substitution.


    Standard I/O and Redirection.


    Timing Commands.

12. Programming the Korn Shell.


    Reading User Input.


    Positional Parameters and Command-Line Arguments.

    Conditional Constructs and Flow Control.

    Looping Commands.



    Trapping Signals.



    The Command Line.


    Built-In Commands.

    Korn Shell Invocation Arguments.

    Lab 33: Korn Shell--Getting Started.

    Lab 34: History.

     Lab 35: Aliases and Functions.

    Lab 36: Shell Metacharacters.

    Lab 37: Tilde Expansion, Quotes, and Command Substitution.

    Lab 38: Redirection.

    Lab 39: Job Control.

    Lab 40: Writing the info Shell Script.

    Lab 41: Variable Expansion of Substrings.

    Lab 42: The lookup Script.

    Lab 43: Using typeset.

    Lab 44: The if/else Construct and the let Command.

    Lab 45: The case Statement.

    Lab 46: The select Loop.

    Lab 47: Autoloading Functions.

13. The Interactive Bash Shell.


    The Environment.

    The Command Line.

    Job Control.

    Command-Line Shortcuts.


    Manipulating the Directory Stack.

    Metacharacters (Wildcards).

    Filename Substitution (Globbing).



    Command Substitution.

    Arithmetic Expansion.

    Order of Expansion.



    Standard I/O and Redirection.


    Shell Invocation Options.

    Shell Built-In Commands.

    Lab 48: bash Shell--Getting Started.

    Lab 49: Job Control.

    Lab 50: Command Completion, History, and Aliases.

    Lab 51: Shell Metacharacters.

    Lab 52: Redirection.

    Lab 53: Variables.

14. Programming the Bash Shell.


    Reading User Input.


    Positional Parameters and Command-Line Arguments.

    Conditional Constructs and Flow Control.

    Looping Commands.


    Trapping Signals.


    The Command Line.

    bash Options.

    Shell Built-In Commands.

    Lab 54: bash Shell--First Script.

    Lab 55: Command-Line Arguments.

    Lab 56: Getting User Input.

    Lab 57: Conditional Statements.

    Lab 58: Conditionals and File Testing.

    Lab 59: The case Statement.

    Lab 60: Loops.

    Lab 61: Functions.

15. Debugging Shell Scripts.


    Style Issues.

    Types of Errors.

    Probable Causes for Syntax Errors.

    Tracing with Shell Options and the set Command.


16. The System Administrator and the Shell.


    The Superuser.

    Becoming a Superuser with the su Command.

    Boot Scripts.


A. Useful UNIX/Linux Utilities for Shell Programmers.

B. Comparison of the Shells.

    The Shells Compared.

    tcsh versus csh.

    bash versus sh.



Download the Index file related to this title.


Submit Errata

More Information

InformIT Promotional Mailings & Special Offers

I would like to receive exclusive offers and hear about products from InformIT and its family of brands. I can unsubscribe at any time.


Pearson Education, Inc., 221 River Street, Hoboken, New Jersey 07030, (Pearson) presents this site to provide information about products and services that can be purchased through this site.

This privacy notice provides an overview of our commitment to privacy and describes how we collect, protect, use and share personal information collected through this site. Please note that other Pearson websites and online products and services have their own separate privacy policies.

Collection and Use of Information

To conduct business and deliver products and services, Pearson collects and uses personal information in several ways in connection with this site, including:

Questions and Inquiries

For inquiries and questions, we collect the inquiry or question, together with name, contact details (email address, phone number and mailing address) and any other additional information voluntarily submitted to us through a Contact Us form or an email. We use this information to address the inquiry and respond to the question.

Online Store

For orders and purchases placed through our online store on this site, we collect order details, name, institution name and address (if applicable), email address, phone number, shipping and billing addresses, credit/debit card information, shipping options and any instructions. We use this information to complete transactions, fulfill orders, communicate with individuals placing orders or visiting the online store, and for related purposes.


Pearson may offer opportunities to provide feedback or participate in surveys, including surveys evaluating Pearson products, services or sites. Participation is voluntary. Pearson collects information requested in the survey questions and uses the information to evaluate, support, maintain and improve products, services or sites, develop new products and services, conduct educational research and for other purposes specified in the survey.

Contests and Drawings

Occasionally, we may sponsor a contest or drawing. Participation is optional. Pearson collects name, contact information and other information specified on the entry form for the contest or drawing to conduct the contest or drawing. Pearson may collect additional personal information from the winners of a contest or drawing in order to award the prize and for tax reporting purposes, as required by law.


If you have elected to receive email newsletters or promotional mailings and special offers but want to unsubscribe, simply email information@informit.com.

Service Announcements

On rare occasions it is necessary to send out a strictly service related announcement. For instance, if our service is temporarily suspended for maintenance we might send users an email. Generally, users may not opt-out of these communications, though they can deactivate their account information. However, these communications are not promotional in nature.

Customer Service

We communicate with users on a regular basis to provide requested services and in regard to issues relating to their account we reply via email or phone in accordance with the users' wishes when a user submits their information through our Contact Us form.

Other Collection and Use of Information

Application and System Logs

Pearson automatically collects log data to help ensure the delivery, availability and security of this site. Log data may include technical information about how a user or visitor connected to this site, such as browser type, type of computer/device, operating system, internet service provider and IP address. We use this information for support purposes and to monitor the health of the site, identify problems, improve service, detect unauthorized access and fraudulent activity, prevent and respond to security incidents and appropriately scale computing resources.

Web Analytics

Pearson may use third party web trend analytical services, including Google Analytics, to collect visitor information, such as IP addresses, browser types, referring pages, pages visited and time spent on a particular site. While these analytical services collect and report information on an anonymous basis, they may use cookies to gather web trend information. The information gathered may enable Pearson (but not the third party web trend services) to link information with application and system log data. Pearson uses this information for system administration and to identify problems, improve service, detect unauthorized access and fraudulent activity, prevent and respond to security incidents, appropriately scale computing resources and otherwise support and deliver this site and its services.

Cookies and Related Technologies

This site uses cookies and similar technologies to personalize content, measure traffic patterns, control security, track use and access of information on this site, and provide interest-based messages and advertising. Users can manage and block the use of cookies through their browser. Disabling or blocking certain cookies may limit the functionality of this site.

Do Not Track

This site currently does not respond to Do Not Track signals.


Pearson uses appropriate physical, administrative and technical security measures to protect personal information from unauthorized access, use and disclosure.


This site is not directed to children under the age of 13.


Pearson may send or direct marketing communications to users, provided that

  • Pearson will not use personal information collected or processed as a K-12 school service provider for the purpose of directed or targeted advertising.
  • Such marketing is consistent with applicable law and Pearson's legal obligations.
  • Pearson will not knowingly direct or send marketing communications to an individual who has expressed a preference not to receive marketing.
  • Where required by applicable law, express or implied consent to marketing exists and has not been withdrawn.

Pearson may provide personal information to a third party service provider on a restricted basis to provide marketing solely on behalf of Pearson or an affiliate or customer for whom Pearson is a service provider. Marketing preferences may be changed at any time.

Correcting/Updating Personal Information

If a user's personally identifiable information changes (such as your postal address or email address), we provide a way to correct or update that user's personal data provided to us. This can be done on the Account page. If a user no longer desires our service and desires to delete his or her account, please contact us at customer-service@informit.com and we will process the deletion of a user's account.


Users can always make an informed choice as to whether they should proceed with certain services offered by InformIT. If you choose to remove yourself from our mailing list(s) simply visit the following page and uncheck any communication you no longer want to receive: www.informit.com/u.aspx.

Sale of Personal Information

Pearson does not rent or sell personal information in exchange for any payment of money.

While Pearson does not sell personal information, as defined in Nevada law, Nevada residents may email a request for no sale of their personal information to NevadaDesignatedRequest@pearson.com.

Supplemental Privacy Statement for California Residents

California residents should read our Supplemental privacy statement for California residents in conjunction with this Privacy Notice. The Supplemental privacy statement for California residents explains Pearson's commitment to comply with California law and applies to personal information of California residents collected in connection with this site and the Services.

Sharing and Disclosure

Pearson may disclose personal information, as follows:

  • As required by law.
  • With the consent of the individual (or their parent, if the individual is a minor)
  • In response to a subpoena, court order or legal process, to the extent permitted or required by law
  • To protect the security and safety of individuals, data, assets and systems, consistent with applicable law
  • In connection the sale, joint venture or other transfer of some or all of its company or assets, subject to the provisions of this Privacy Notice
  • To investigate or address actual or suspected fraud or other illegal activities
  • To exercise its legal rights, including enforcement of the Terms of Use for this site or another contract
  • To affiliated Pearson companies and other companies and organizations who perform work for Pearson and are obligated to protect the privacy of personal information consistent with this Privacy Notice
  • To a school, organization, company or government agency, where Pearson collects or processes the personal information in a school setting or on behalf of such organization, company or government agency.


This web site contains links to other sites. Please be aware that we are not responsible for the privacy practices of such other sites. We encourage our users to be aware when they leave our site and to read the privacy statements of each and every web site that collects Personal Information. This privacy statement applies solely to information collected by this web site.

Requests and Contact

Please contact us about this Privacy Notice or if you have any requests or questions relating to the privacy of your personal information.

Changes to this Privacy Notice

We may revise this Privacy Notice through an updated posting. We will identify the effective date of the revision in the posting. Often, updates are made to provide greater clarity or to comply with changes in regulatory requirements. If the updates involve material changes to the collection, protection, use or disclosure of Personal Information, Pearson will provide notice of the change through a conspicuous notice on this site or other appropriate way. Continued use of the site after the effective date of a posted revision evidences acceptance. Please contact us if you have questions or concerns about the Privacy Notice or any objection to any revisions.

Last Update: November 17, 2020