You are previewing Shell Scripting: Expert Recipes for Linux, Bash, and More.
O'Reilly logo
Shell Scripting: Expert Recipes for Linux, Bash, and More

Book Description

A compendium of shell scripting recipes that can immediately be used, adjusted, and applied

The shell is the primary way of communicating with the Unix and Linux systems, providing a direct way to program by automating simple-to-intermediate tasks. With this book, Linux expert Steve Parker shares a collection of shell scripting recipes that can be used as is or easily modified for a variety of environments or situations. The book covers shell programming, with a focus on Linux and the Bash shell; it provides credible, real-world relevance, as well as providing the flexible tools to get started immediately.

  • Shares a collection of helpful shell scripting recipes that can immediately be used for various of real-world challenges

  • Features recipes for system tools, shell features, and systems administration

  • Provides a host of plug and play recipes for to immediately apply and easily modify so the wheel doesn't have to be reinvented with each challenge faced

Come out of your shell and dive into this collection of tried and tested shell scripting recipes that you can start using right away!

Table of Contents

  1. Cover
  2. Contents
  3. Part I: About the Ingredients
    1. Chapter 1: The History of Unix, GNU, and Linux
      1. Unix
      2. GNU
      3. Linux
      4. Summary
    2. Chapter 2: Getting Started
      1. Choosing an OS
      2. Choosing an Editor
      3. Setting Up the Environment
      4. Summary
    3. Chapter 3: Variables
      1. Using Variables
      2. Preset and Standard Variables
      3. SECONDS
      4. Summary
    4. Chapter 4: Wildcard Expansion
      1. Filename Expansion (Globbing)
      2. Regular Expressions and Quoting
      3. Summary
    5. Chapter 5: Conditional Execution
      1. If/Then
      2. Else
      3. elif
      4. Test ([)
      5. Case
      6. Summary
    6. Chapter 6: Flow Control Using Loops
      1. For Loops
      2. While Loops
      3. Nested Loops
      4. Breaking and Continuing Loop Execution
      5. While with Case
      6. Until Loops
      7. Select Loops
      8. Summary
    7. Chapter 7: Variables Continued
      1. Using Variables
      2. Searching Strings
      3. Providing Default Values
      4. Indirection
      5. Sourcing Variables
      6. Summary
    8. Chapter 8: Functions and Libraries
      1. Functions
      2. Variable Scope
      3. Libraries
      4. Getopts
      5. Summary
    9. Chapter 9: Arrays
      1. Assigning Arrays
      2. Accessing Arrays
      3. Associative Arrays
      4. Manipulating Arrays
      5. Advanced Techniques
      6. Summary
    10. Chapter 10: Processes
      1. The ps Command
      2. killall
      3. The /proc pseudo-filesystem
      4. prtstat
      5. I/O Redirection
      6. Exec
      7. Pipelines
      8. Background Processing
      9. Other Features of /proc and /sys
      10. Summary
    11. Chapter 11: Choosing and Using Shells
      1. The Bourne Shell
      2. The KornShell
      3. The C Shell
      4. The Tenex C Shell
      5. The Z Shell
      6. The Bourne Again Shell
      7. The Debian Almquist Shell
      8. Dotfiles
      9. Command Prompts
      10. Aliases
      11. History
      12. Tab Completion
      13. Foreground, Background, and Job Control
      14. Summary
  4. Part II: Recipes for Using and Extending System Tools
    1. Chapter 12: File Manipulation
      1. stat
      2. cat
      3. cat Backwards is tac
      4. Redirection
      5. dd
      6. df
      7. mktemp
      8. join
      9. install
      10. grep
      11. split
      12. tee
      13. touch
      14. find
      15. find -exec
      16. Summary
    2. Chapter 13: Text Manipulation
      1. cut
      2. echo
      3. Fmt
      4. Head and Tail
      5. od
      6. paste
      7. pr
      8. printf
      9. shuf
      10. sort
      11. tr
      12. uniq
      13. wc
      14. Summary
    3. Chapter 14: Tools for Systems Administration
      1. basename
      2. date
      3. dirname
      4. factor
      5. identity, groups, and getent
      6. logger
      7. md5sum
      8. mkfifo
      9. Networking
      10. nohup
      11. seq
      12. sleep
      13. timeout
      14. uname
      15. uuencode
      16. xargs
      17. yes
      18. Summary
  5. Part III: Recipes for Systems Administration
    1. Chapter 15: Shell Features
      1. Recipe 15-1: Installing Init Scripts
      2. Recipe 15-2: RPM Report
      3. Recipe 15-3: Postinstall Scripts
    2. Chapter 16: Systems Administration
      1. Recipe 16-1: init Scripts
      2. Recipe 16-2: CGI Scripts
      3. Recipe 16-3: Configuration Files
      4. Recipe 16-4: Locks
    3. Chapter 17: Presentation
      1. Recipe 17-1: Space Game
    4. Chapter 18: Data Storage and Retrieval
      1. Recipe 18-1: Parsing HTML
      2. Recipe 18-2: CSV Formatting
    5. Chapter 19: Numbers
      1. Recipe 19-1: The Fibonacci Sequence
      2. Recipe 19-2: PXE Booting
    6. Chapter 20: Processes
      1. Recipe 20-1: Process Control
    7. Chapter 21: Internationalization
      1. Recipe 21-1: Internationalization
  6. Part IV: Reference
    1. Appendix: Further Reading
      1. Shell Tutorials and Documentation
      2. Shell Services
    2. Glossary
  7. Introduction
    1. What This Book Covers
    2. How This Book Is Structured
    3. What You Need to Use This Book
    4. Conventions
    5. Source Code
    6. Errata
    7. p2p.wrox.com
  8. Advertisement