Bash · Foundations

Learn Bash

The syntax and the mental model. Short, runnable, no fluff.

Learn the Basics

01

Hello, World!

The tutorial discusses shell programming in general with focus on Bash (“Bourne Again Shell”) shell as the main shell interpreter.

02

Variables

Shell variables are created once they are assigned a value. A variable can contain a number, a character or a string of characters.

03

Passing Arguments to the Script

Arguments can be passed to the script when it is executed, by writing them as a space-delimited list following the script file name.

04

Arrays

An array can hold several values under one name. Array naming is the same as variables naming.

05

Basic Operators

Arithmetic Operators Simple arithmetics on variables can be done using the arithmetic expression: $((expression)) The basic operators are: a + b addition (a plus b) a - b substraction (a minus b) a b multiplication (a times b) a / b division (integer) (a divided by b) a % b modulo (the integer remainder of a divided by b) a b exponentiation (a to the power of b)

06

Basic String Operations

The shell allows some common string operations which can be very useful for script writing.

07

Decision Making

As in popular programming languages, the shell also supports logical decision making.

08

Loops

For each pass through the loop, arg takes on the value of each successive value in the list. Then the command(s) are executed.

09

Array-Comparison

Comparison of arrays Shell can handle arrays An array is a variable containing multiple values. Any variable may be used as an array.

10

Shell Functions

Like other programming languages, the shell may have functions. A function is a subroutine that implements a set of commands and operations.

11

Case Statements

Pattern matching on a string — cleaner than a chain of if/elif, and the backbone of every argument parser and dispatch table in shell.

Advanced Tutorials

Get the Bash agent pack

A battle-tested AGENTS.md, the review checklist, and the failure-mode cheat sheet for Bash. One email, then occasional updates when the tooling shifts. No course pitch.

Unsubscribe in one click. We never sell the list. Or just take the AGENTS.md now — no email needed.