Beginning Portable Shell Scripting: From Novice to Professional

Book description

Portable shell scripting is the future of modern Linux, OS X, and Unix command–line access. Beginning Portable Shell Scripting: From Novice to Professional teaches shell scripting by using the common core of most shells and expands those principles to all of scripting.

You will learn about portable scripting and how to use the same syntax and design principles for all shells. You'll discover about the interaction between shells and other scripting languages like Ruby and Python, and everything you learn will be shown in context for Linux, OS X, bash, and AppleScript.

What you'll learn

This book will prime you on not just shell scripting, but also the modern context of portable shell scripting. You will learn

  • The core Linux/OS X shell constructs from a portability point of view

  • How to write scripts that write other scripts, and how to write macros and debug them

  • How to write and design shell script portably from the ground up

  • How to use programmable utilities and their inherent portability to your advantage, while pinpointing potential traps

  • Pulling everything together, how to engineer scripts that play well with Python and Ruby, and even run on embedded systems

  • Who this book is for

    This book is for system administrators, programmers, and testers working across Linux, OS X, and the Unix command line

    Table of contents

    1. Title Page
    2. Dedication
    3. Contents at a Glance
    4. Contents
    5. About the Author
    6. About the Technical Reviewer
    7. Acknowledgments
    8. CHAPTER 1: Introduction to Shell Scripting
      1. About This Book
      2. Introducing the Shell
      3. What's Next?
    9. CHAPTER 2: Patterns and Regular Expressions
      1. Shell Patterns
      2. Pathname Expansion
      3. Regular Expressions
      4. What's Next?
    10. CHAPTER 3: Basic Shell Scripting
      1. Introducing Control Structures
      2. Introducing Redirection
      3. What's Next?
    11. CHAPTER 4: Core Shell Features Explained
      1. Parsing
      2. Shell Quoting
      3. Substitution and Expansion
      4. What's Next?
    12. CHAPTER 5: Shells Within Shells
      1. Understanding Processes
      2. Variables and the Environment
      3. Exploring Subshells
      4. Modifying the State of the Shell
      5. Using Shells Within Shells
      6. What's Next?
    13. CHAPTER 6: Invocation and Execution
      1. Shell Invocation
      2. Execution
      3. What's Next?
    14. CHAPTER 7: Shell Language Portability
      1. More on Portability
      2. Common Extensions and Omissions
      3. Common Shells and Their Features
      4. Execution Preambles
      5. What's Next?
    15. CHAPTER 8: Utility Portability
      1. Common Variations
      2. Avoiding Unnecessary Dependencies
      3. Common Utility Issues
      4. What to Do When Something Is Unavailable
      5. What's Next?
    16. CHAPTER 9: Bringing It All Together
      1. Robustness
      2. Degrade Gracefully
      3. Scripts That Write Scripts
      4. What's Next?
    17. CHAPTER 10: Shell Script Design
      1. Do One Thing Well
      2. Command-Line Options and Arguments
      3. Set Reasonable Limits
      4. Case Study: pids
      5. What's Next?
    18. CHAPTER 11: Mixing and Matching
      1. Mixing Quoting Rules
      2. Embedding Shell Scripts in Code
      3. Embedding Code in Shell Scripts
      4. Utilities and Languages
      5. What's Next?
    19. APPENDIX A: The Shell Command Language
      1. 2. Shell Command Language
    20. APPENDIX B: The sh Utility
      1. Name
      2. Synopsis
      3. Description
      4. Options
      5. Operands
      6. Stdin
      7. Input Files
      8. Environment Variables
      9. Asynchronous Events
      10. Stdout
      11. Stderr
      12. Output Files
      13. Extended Description
      14. Exit Status
      15. Consequences Of Errors
      16. Application Usage
      17. Rationale
      18. Future Directions
      19. See Also
      20. Change History
      21. Issue 5
      22. Issue 6
    21. APPENDIX C: Regular Expressions
      1. 9. Regular Expressions
    22. Index

    Product information

    • Title: Beginning Portable Shell Scripting: From Novice to Professional
    • Author(s):
    • Release date: November 2008
    • Publisher(s): Apress
    • ISBN: 9781430210436