Welcome to

The newline Guide to Bash Scripting

Example Code Download

You can download the complete example code by clicking here.

Introduction

7 lessons

Community and Code Downloads

Here's where you'll find the code downloads and Discord channel

LESSON

Conventions used in this book

First stop, orientation

LESSON

Self–Help

7 lessons

Command documentation

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:

LESSON

LESSON

Editing Commands and Scripts

2 lessons

LESSON

LESSON

Copying and Pasting

6 lessons

Listing Files

3 lessons

Text

3 lessons

LESSON

LESSON

LESSON

Math

7 lessons

LESSON

Arithmetic evaluation

then echo "x is bigger" else echo "y is bigger" fi y is bigger \```

LESSON

LESSON

Time

4 lessons

Output

4 lessons

LESSON

LESSON

LESSON

LESSON

JSON

2 lessons

LESSON

Filtering

{"username":"jdoe","password":"sec\\ret$"} EOF $ jq . ./credentials.json { "username": "jdoe", "password": "sec\\ret$" } \```

LESSON

XML

5 lessons

LESSON

Pulling out a value

<configuration> <password>foo &amp; bar</password> </configuration> EOF $ password="$(xml_grep --text_only '/configuration/password' ./test.xml)" $ printf '%s\n' "$password" foo & bar ```

LESSON

Creating

\--stringparam username jdoe --stringparam password 'foo > bar' ./authentication.xslt - &lt;&lt;&lt; '<x/>' \```

LESSON

Images

6 lessons

LESSON

Metadata

\--tag=Copyright ./image.jpg Wrote file './new.jpg'. $ exif --tag=Copyright --machine-readable ./new.jpg Copyright Victor Engmark (Photographer) - [None](Editor) \```

LESSON

Archiving and Compression

5 lessons

From the Terminal to Production

8 lessons

LESSON

Cleaning up

example text $ echo "$line" original value \```

LESSON

Fail–Fast Settings

6 lessons

LESSON

LESSON

LESSON

pipefail

grep: ./README.md: No such file or directory

LESSON

failglob

do grep foo "$file" done grep: ./\*: No such file or directory \```

LESSON

Version Control

4 lessons

Gitting stuff done

# Fullstack Bash Scripting notes & code

LESSON

LESSON

Quality Assurance

3 lessons

Signals

3 lessons

Summary and Changelog

2 lessons

LESSON

LESSON