# Learn Bash > Free Bash and shell tutorials, plus how to write scripts and agent hooks that fail safely. Canonical: https://learn-bash.net/ Licence: content free to read and quote with attribution to Learn Bash (https://learn-bash.net/). Maintainer: Code Learning Dojo. Last built 2026-09-06. ## Foundations The syntax and the mental model. Short, runnable, no fluff. - [Hello, World!](https://learn-bash.net/hello-world/): The tutorial discusses shell programming in general with focus on Bash (“Bourne Again Shell”) shell as the main shell interpreter. - [Variables](https://learn-bash.net/variables/): Shell variables are created once they are assigned a value. A variable can contain a number, a character or a string of characters. - [Passing Arguments to the Script](https://learn-bash.net/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. - [Arrays](https://learn-bash.net/arrays/): An array can hold several values under one name. Array naming is the same as variables naming. - [Basic Operators](https://learn-bash.net/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) - [Basic String Operations](https://learn-bash.net/basic-string-operations/): The shell allows some common string operations which can be very useful for script writing. - [Decision Making](https://learn-bash.net/decision-making/): As in popular programming languages, the shell also supports logical decision making. - [Loops](https://learn-bash.net/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. - [Array-Comparison](https://learn-bash.net/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. - [Shell Functions](https://learn-bash.net/shell-functions/): Like other programming languages, the shell may have functions. A function is a subroutine that implements a set of commands and operations. - [Case Statements](https://learn-bash.net/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. - [Special Variables](https://learn-bash.net/special-variables/): In last tutorial about shell function, you use “$1” represent the first argument passed to functionA. - [Bash trap command](https://learn-bash.net/bash-trap-command/): It often comes the situations that you want to catch a special signal/interruption/user input in your script to prevent the unpredictables. - [Input Parameter Parsing](https://learn-bash.net/input-parameter-parsing/): Turning $@ into a usable set of options: manual loops, getopts, long flags, and the --dry-run habit that makes a script safe to run once. - [File Testing](https://learn-bash.net/file-testing/): Often you will want to do some file tests on the file system you are running. In this case, shell will provide you with several useful commands to achieve it. - [Pipelines](https://learn-bash.net/pipelines/): Pipelines, often called pipes, is a way to chain commands and connect output from one command to the input of the next. - [Process Substitution](https://learn-bash.net/process-substitution/): In the previous section we’ve seen how to chain output of one command to the next one. - [Regular Expressions](https://learn-bash.net/regular-expressions/): Bash has a regex operator built in, and it is better than piping to grep for most jobs — once you know the two quoting rules that trip everyone up. - [Special Commands: sed, awk, grep, sort](https://learn-bash.net/special-commands-sed-awk-grep-sort/): The four tools that do most of the work in most shell scripts, and the small subset of each that is worth memorising. - [Redirection and Here Documents](https://learn-bash.net/here-documents-and-redirection/): Where output goes, where input comes from, and how to embed a block of text in a script without fighting quotes. ## AI-Native Configuring agents, harnesses and feedback loops for this language. Updated as the tooling moves. - [Shell scripts as agent guardrails](https://learn-bash.net/ai/hooks-and-guardrails/): Your agent runs more shell than anything else, and shell is the one place a mistake is not recoverable. Here is how to write the scripts that keep it honest. - [Writing an AGENTS.md for shell-heavy projects](https://learn-bash.net/ai/agents-md/): The shortest useful instructions file on this network — four lines of script header, a shellcheck rule, and one sentence about when to stop writing shell at all. - [Tracking what your coding agent costs you](https://learn-bash.net/ai/tokenomics/): Your agent already writes a complete record of every session to disk. Twenty lines of shell turns it into a spend report, and one hook keeps it honest. ## Review & Verify How generated code fails in this language, and the checks that catch it before your users do. - [The shell mistakes language models actually make](https://learn-bash.net/review/failure-modes/): Generated shell is usually correct on the happy path and dangerous on every other one. Almost all of it is caught by one tool. - [What your script depends on, when there is no package manager](https://learn-bash.net/review/dependencies/): A shell script's dependencies are every external command it calls, every flag it assumes, and every installer it pipes into a shell. None of that is declared anywhere. - [Security review checklist for generated shell scripts](https://learn-bash.net/review/security/): Shell has no sandbox, no type system and no undo. Every variable is a potential injection point and every script runs with your full privileges. - [The performance traps in generated shell scripts](https://learn-bash.net/review/performance/): Shell performance is almost entirely about how many processes you start. Generated scripts start a great many, and the fix is usually to delete code rather than add it. ## Reference pages - [About Learn Bash, and how we make money](https://learn-bash.net/about/): Editorial policy, sourcing, corrections and affiliate disclosure for Learn Bash, part of the Code Learning Dojo network. - [The shell stack we would set up today](https://learn-bash.net/tools/): An opinionated shell toolchain: shellcheck, shfmt, modern CLI replacements, terminal choice, and when to switch from bash to a real language.