The newline Guide to Bash Scripting
Bash is the most popular shell and here we'll teach you popular tools, techniques, pitfalls and workarounds. Bash is simple to get started with, hard to master, and you can do incredible things with a line or two – inside we'll teach you how.
What You Will Learn
How to find help on arbitrary commands
How to create robust, maintainable scripts
The importance of error handling settings
How to use many popular tools
What Bash is good and bad at
Bash is everywhere. It has grown to be the most popular shell on *nixes – including Mac OS X and Windows Subsystem Linux (WSL).
The newline Guide to Bash Scripting is an exploration of the Bash shell, scripting language and related tools. It’s aimed at developers who want to get the job done right the first time, and make sure maintenance is a breeze. Topics include:
- how to find help on arbitrary commands
- how to structure a robust and maintainable script
- editing commands and interacting with the terminal efficiently
- tools for dealing with version control, JSON, XML, text encodings, images and compressed files
- quality assurance
- … and much more
The goal of this book is to give you the tools and techniques to write Bash scripts which will stand the test of time, and to give you the means to explore the vast shell scripting ecosystem to find the tools you need right now.
Bash is the Linux glue language, so this book is aimed at software developers mainly working in some other language. We assume that you have working knowledge of programming concepts like variable assignments, loops and files, and at least a passing familiarity with interactive shells.
If you're comfortable with web development, but not–so–comfortable on the commandline then this course is perfect for you.
Precedence is the same here as you might be familiar with from arithmetic. For example, multiplication has higher precedence than addition, so 2 + 3 × 4 is equal to 2 + (3 × 4), or 14. A common use case for this is to define a function with the same name as a file command to set some default options. As a quick example, here’s how we would tell `grep` to use colored output by default:
Copying and Pasting
Pulling out a value
<configuration> <password>foo & bar</password> </configuration> EOF $ password="$(xml_grep --text_only '/configuration/password' ./test.xml)" $ printf '%s\n' "$password" foo & bar ```
\--stringparam username jdoe --stringparam password 'foo > bar' ./authentication.xslt - <<< '<x/>' \```
Archiving and Compression
From the Terminal to Production
Frequently Asked Questions
Who is this course for?
This book is aimed at software developers mainly working in some other language who want to get better at using the CLI and writing Bash Scripts.
What if I need help?
You can ask us questions anytime through the community Discord channel.
Learn to use the CLI
Automate repetitive tasks
Build powerful one-liners without writing code
12 complete projects
836 lines of code