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)


Aliases are quick and simple ways to make one command stand for a whole command line, expressed as a string. They are perhaps the best-known way to customize behavior in the Bash shell, but they are also the least flexible.

Depending on your system, it's possible you already have an alias or two defined by your startup scripts. When the builtin alias command is entered with no arguments, it lists all of the aliases defined in the current Bash session.

For example, on a Debian GNU/Linux server, a new user might have the following alias defined:

bash$ alias
alias ls='ls --color=auto'

This is also evident from running the type command on ls with the -a switch, which informs us that the command used is an alias:

bash$ type -a ls
ls is aliased to `ls --color=auto'
ls is /bin/ls

The purpose of this ls alias is to add the --color=auto option to any call to...