Contents: Bash Reference Sheet

TableOfContents

Basic Structures

Compound Commands

Compound commands are statements that can execute several commands but are considdered as a sort of command group by Bash.

Command Lists

Expressions

Loops

Builtins

Builtins are commands that perform a certain function that has been compiled into Bash. Understandably, they are also the only types of commands (other than those above) that can modify the Bash shell's environment.

Dummies

Declarative

Input

Output

Execution

Jobs/Processes

Conditionals And Loops

Arguments

Tests

Exit Codes

An Exit Code or Exit Status is an unsigned 8-bit integer returned by a command that indicates how its execution went. It is agreed that an Exit Code of 0 indicates the command was successful at what it was supposed to do. Any other Exit Code indicates that something went wrong. Applications can choose for themselves what number indicates what went wrong; so refer to the manual of the application to find out what the application's Exit Code means.

Testing The Exit Code

Patterns

Bash knows two types of patterns. Glob Patterns is the most important, most used and best readable one. Later versions of Bash also support the "trendy" Regular Expressions. It is however ill-adviced to use regular expressions in scripts unless you have absolutely no other choice or its use greatly outweighs the use of globs in advantages. Generally speaking, if you need a regular expression, you'll be using awk(1), sed(1), or grep(1) instead of Bash.

Glob Syntax

Testing Patterns

Examples: Basic Structures

Compound Commands

Command Lists

Expressions

Loops

BR(The last character will be a comma, yes, if you really want to get rid of it; you can - but it defeats the simplicity of this example)

Builtins

Dummies

Declarative

Input

Output

Execution