Share E-Book
Scan to open this page

Scan with your phone to open this page

Author: Jayant Varma, Chris F. A. Johnson

Rating No ratings yet

Learn how to effectively utilize the Bash shell in your programming. This refreshed and expanded third edition has been updated to Bash 5.2, and many scripts have been rewritten to make them more idiomatically Bash, taking better advantage of features specific to Bash. It is easy to read, understand, and will teach you how to get to grips with Bash programming without drowning you in pages and pages of syntax. Using this book you will be able to use the shell efficiently, make scripts run faster using expansion and external commands, and understand how to overcome many common mistakes that cause scripts to fail. This book is perfect for all beginning Linux and Unix system administrators who want to be in full control of their systems, and really get to grips with Bash programming. The Bash shell is a complete programming language, not merely a glue to combine external Linux commands. By taking full advantage of Shell internals, Shell programs can perform as snappily as utilities written in C or other compiled languages. And you will see how, without assuming UNIX lore, you can write professional Bash programs through standard programming techniques. What You'll Learn • Use the Bash shell to write utilities and accomplish most programming tasks • Replace many external commands with shell parameter expansion making scripts very fast • Avoid many common mistakes that cause scripts to fail • See how Bash’s read line and history libraries can save typing when getting user input • Build shell scripts that get information from the Web Who This Book Is For Developers, programmers, and open source enthusiasts who want to write scripts using Bash on multiple platforms

AI Reading Assistant

Whole-book reading guide from stratified index samples; jump to passages in the text

AI guide
【One-Line Pitch】 A practical, idiom-focused guide to treating Bash as a full programming language rather than a command glue layer, updated for Bash 5.2. Best for developers, sysadmins, and open-source enthusiasts who want faster, more reliable scripts without wading through endless syntax. 【Book Arc】 - **Opening (~0%–13%)**: Frames Bash as a complete programming language and sets expectations for the third edition—Bash 5.2 coverage, rewritten idiomatic scripts, and a focus on avoiding common failure modes. - **Early (~13%–27%)**: Gets you writing immediately with the first shell program, covering script files, naming, directory placement, editors, and a basic "Hello, World!" workflow. - **Early (~27%–33%)**: Moves into input, output, and throughput: positional and special parameters, variables, arguments vs. options, and why `echo` should be avoided. - **Middle (~33%–60%)**: Continues the I/O theme with `printf` formatting, escape sequences, format specifiers, width control, printing to variables, and line continuation. - **Late (~60%–87%)**: Covers standard streams and redirection (`>`, `>>`, `<`), reading input, pipelines, and command substitution—the core of composing shell programs. - **Ending (~87%–100%)**: Introduces looping and branching: exit status, expression testing with `test`, `[ … ]`, file/integer/string tests, and the enhanced `[[ … ]]` construct. 【Key Takeaways】 - **Bash is a programming language, not just glue** (Opening): The book's central premise is that shell internals let Bash programs approach the speed of compiled utilities. This reframes how you approach scripting. - **Idiomatic Bash beats portable-but-clunky Bash** (Opening): The third edition rewrites scripts to exploit Bash-specific features rather than writing lowest-common-denominator shell code. - **Parameter expansion can replace external commands** (Early): Using shell expansion instead of spawning processes is a major performance lever and a recurring theme. - **Avoid `echo`; prefer `printf`** (Early–Middle): The excerpts explicitly flag `echo` as something to avoid, with `printf` offering reliable formatting, escape sequences, and width control. - **Special parameters are the plumbing of scripts** (Early): `*`, `@`, `#`, `0`, `$`, `?`, `_`, `!`, `-` govern arguments, status, and process context—essential for correct scripts. - **Redirection and pipelines are composition primitives** (Late): `>`, `>>`, `<`, pipelines, and command substitution are how small programs become larger tools. - **Exit status drives control flow** (Ending): Testing expressions and branching on exit status is the foundation of looping and decision-making in Bash. - **Test syntax matters** (Ending): The distinction between `test`/`[ … ]` and the enhanced `[[ … ]]` affects correctness and readability. 【Reading Tips】 - **Deep-read the early I/O chapters**: Parameters, `printf`, and redirection are the vocabulary you'll use in every later script; skimming here costs you later. - **Skim the setup material**: Script naming, directory selection, and editor choice are one-time concerns—read once, then move on. - **Practice the test constructs**: The `[ … ]` vs. `[[ … ]]` distinction is a common source of bugs; type out examples rather than just reading them. - **Keep the book's premise in mind**: Whenever you reach for an external command, ask whether parameter expansion or a builtin could do it faster. - **Use the exercises**: The excerpts show commands, concepts, and exercises at chapter ends—these are the fastest way to convert reading into skill. 【Coverage Limits】 The excerpts cover the front matter, table of contents, and early chapters through looping and branching; later chapters on web-facing scripts, readline/history usage, and advanced topics are referenced in the blurb but not detailed in the excerpts. Specific chapter titles beyond Chapters 1–3 are not covered.
Excerpt 1
ux Shell — Third Edition — Jayant Varma Chris F. A. Johnson Pro Bash Learn to Script and Program the GNU/Linux Shell Third Edition Jayant Varma Chris F. A. J...
View in text
Page 5
6 Building a Better “Hello, World!” 7 Summary 7 Commands 8 Concepts 8 Variables 9 Exercises 9 Chapter 2: Input, Output, and Throughput 11 Parameters and Vari...
View in text
Page 5
14 Table of Contents
View in text
Page 5
14 Table of Contents
View in text
Page 5
14 Table of Contents
View in text
Excerpt 6
14 Table of Contents vi printf: Formatting and Printing Data 15 Escape Sequences 16 Format Specifiers 16 Width Specification 18 Printing to a Variable 20 Lin...
View in text
Page 6
25 Exercises 26 Chapter 3: Looping and Branching 27 Exit Status 27 Testing an Expression 28 test, aka [ … ] 28 File Tests 28 Integer Tests 29 String Tests 29...
View in text
Tags
AI categories
Programming LanguageLinuxDevOps
ISBN: 1484295870
Publisher: Apress
Publish Year: 2023
Language: English
Pages: 314
File Format: PDF
File Size: 2.7 MB
Text Preview (First 20 pages)
Registered users can read the full content for free

Register as a Gaohf Library member to read the complete e-book online for free and enjoy a better reading experience.

Generating text preview…