A free, self-paced textbook in 8 chapters. Read a chapter, then drill it with the 120 companion flashcards using spaced repetition.
Bash, the Bourne Again SHell, is a Unix shell and command language written as a free software replacement for the original Bourne shell. It serves as the default login shell on mos...
A Bash variable is a named storage location for a value. Variables are assigned with NAME=value — critically, with no spaces around the = sign, because Bash treats VAR = value as a...
Conditional execution in Bash revolves around if, elif, else, and fi. The condition itself is a list of commands whose exit status determines the branch: zero is true and non-zero...
Bash offers several ways to iterate. The most basic form is for name in list; do body; done, where the list may be a literal set of words, a glob, the output of a command substitut...
Functions are defined in Bash with name() { commands; } or with the keyword form function name { commands; }. The body of a function executes in the same shell environment as the c...
Bash supports both indexed arrays and associative arrays (dictionaries). Indexed arrays are declared with arr=(one two three) or by element with arr[0]=one, and individual elements...
The read builtin is the primary way to ingest input. read -rp "Prompt: " answer reads a single line with a prompt and without backslash interpretation, while while IFS= read -r lin...
A subshell, written ( commands ) or produced by backgrounding, runs its commands in a child of the current shell. Any changes to variables, the working directory, or shell options...