Skip to main content

Introduction to Advanced Bash Usage

James Pannacciulli (Media Temple)
Tools & Techniques
Portland 256
Average rating: ***..
(3.83, 6 ratings)
Slides:   1-PDF 

Broad introduction to Bash features for users who want to go beyond simple command execution. The intended audience ranges from marginally experienced to veteran Bash users.

The distinction between various command types (file, builtin, function, keyword), as well as how to find appropriate system and command documentation (type, help, apropos, man, info) will be covered. You should be able to effectively identify the type of a command and find the available system documentation on Linux for that command after this presentation.

There will be demonstration of the effictive usage of compound commands like loops (for, while, until, select), conditionals (if, case), and command groups (current shell and subshell), showing how they can be used to build functions. String and arithmetic tests and return values will be discussed. A special emphasis will be given to the use of for and while loops for iterating over lists to automate common or complex tasks; this part is very useful, especially when the lists are dynamically generated as the output of other commands in a pipeline or from a subshell.

The presentation will explore the use of parameter expansion (variable substitution, or interpolation, and indirection), string manipulation (subsetting, matching, replacing), and brace expansion (this one is fun). These constructs will allow you to use Bash itself for many operations that you may currently be invoking subshells and pipelines for. There will be a brief review of pipelines and subshells.

This talk should be accessible, but will move at a swift pace and cover lots of ground; regardless of your level of expertise, you should come out learning something, with good code examples to review after the talk.

Photo of James Pannacciulli

James Pannacciulli

Media Temple

James Pannacciulli has been an enthusiast and user of GNU/Linux and related software since 1997 and is a supporter of the free (libre) software movement. He holds an MA and BA in theoretical linguistics from UCLA and Rutgers universities, respectively, and is currently a Systems Engineer at Media Temple.

James has presented on Bash at SCALE and UUASC in Los Angeles.