Book Image

Bash Quick Start Guide

By : Tom Ryder
Book Image

Bash Quick Start Guide

By: Tom Ryder

Overview of this book

Bash and shell script programming is central to using Linux, but it has many peculiar properties that are hard to understand and unfamiliar to many programmers, with a lot of misleading and even risky information online. Bash Quick Start Guide tackles these problems head on, and shows you the best practices of shell script programming. This book teaches effective shell script programming with Bash, and is ideal for people who may have used its command line but never really learned it in depth. This book will show you how even simple programming constructs in the shell can speed up and automate any kind of daily command-line work. For people who need to use the command line regularly in their daily work, this book provides practical advice for using the command-line shell beyond merely typing or copy-pasting commands into the shell. Readers will learn techniques suitable for automating processes and controlling processes, on both servers and workstations, whether for single command lines or long and complex scripts. The book even includes information on configuring your own shell environment to suit your workflow, and provides a running start for interpreting Bash scripts written by others.
Table of Contents (10 chapters)

Quoting

The way you can reliably include characters that are special to Bash literally in a command line is to quote them. Quoting special characters makes Bash ignore any special meaning they may otherwise have to the shell, and instead use them as plain characters, like a-z or 0-9. This works for almost any special character.

We say "almost", because there's one exception: there's no way to escape the null character (ASCII NUL, 0x00) in a shell word.

Quoting is the most important thing that even experienced people who write shell script sometimes get wrong. Even a lot of very popular documentation online fails to quote correctly in example scripts! If you learn to quote correctly, you will save yourself a lot of trouble down the line. The way quoting in shell script works very often surprises people coming from other programming languages.

We will look at...