
Bash Shell Scripting Cheat Sheet

Get the cheat sheet
About
Bash is a command language interpreter: a version of the classic Unix shell with many enhancements. Bash is the default shell installed on GNU/Linux distributions and many other Unix-style systems, such as macOS.
Although most developers have a working knowledge of Bash for everyday interactive use, few know the rich features it offers for writing scripts. It supports most of the statements that other languages provide, such as indexed and associative arrays, foreground/background task execution, pipes, redirections, loops, functions, and Boolean expressions.
In this cheat sheet you will learn how to:
- Create Bash scripts
- Manipulate strings
- Create credentials
- Control script flow with conditionals and loops
- Use collections
Excerpt
Print all elements from a plain array:
for i in "${names[@]}"; do
echo "Hello $i"
done
Print keys and values of all elements from a key/value array:
for key in "${!score[@]}"; do
echo $key
done
for val in "${score[@]}"; do
echo $val
done