Printable Bash Scripting Cheat Sheet
Free printable Bash scripting cheat sheet at exact scale — the everyday shell-scripting syntax grouped by task: script basics, variables, parameters, string manipulation, tests, conditionals, loops, functions, arrays, arithmetic, redirection and error handling, all on one page.
This Bash cheat sheet gathers the syntax you actually use when writing shell scripts and groups it by what you’re trying to do — the shebang and safe-mode flags (set -euo pipefail), assigning and expanding variables with parameter defaults like ${var:-default}, handling positional parameters and special variables ($1, $@, $?, $$), and manipulating strings with substring, trim and replace expansions.
It also covers file and string tests with [[ ]], if/case conditionals, for/while/until loops, defining functions with local variables, indexed and associative arrays, command substitution and integer arithmetic, input/output redirection, pipes, here-documents, and robust scripting with trap, exit codes, getopts and shellcheck. It’s an ideal desk reference whether you’re learning Bash or just want the syntax at a glance, and it prints at exact scale in real millimetres on A4, Letter or any size.
Printing at exact scale
Every sheet is drawn in real millimetres and prints at exact physical scale. For accurate output, set Scale = 100% (Actual size) and Margins = None in your browser's print dialog. Not sure your printer is honest? Run the printer ruler test first to confirm 50 mm really measures 50 mm. Prefer a file? Use the PDF, PNG or SVG buttons to download the sheet instead of printing — PDF and SVG keep the exact dimensions, and PNG is a 300 DPI image.
Frequently asked questions
Which Bash topics are covered?
Script basics and safe mode, variables and parameter expansion, positional and special variables, string manipulation, file and string tests, if/case conditionals, for/while/until loops, functions, indexed and associative arrays, command substitution and arithmetic, input/output redirection and here-docs, plus traps, exit codes, getopts and shellcheck.
What is set -euo pipefail?
A common safe-mode line: set -e exits on any error, set -u errors on unset variables, and set -o pipefail makes a pipeline fail if any stage fails. Together they catch bugs early instead of letting a broken script keep running.
What’s the difference between [ ] and [[ ]]?
[ ] is the POSIX test command; [[ ]] is a Bash keyword that’s safer and more capable — it supports == pattern matching, =~ regex and &&/|| without word-splitting surprises. Prefer [[ ]] in Bash scripts.
How do I loop over lines in a file safely?
Use while read -r line; do …; done < file. The -r stops backslash mangling, and redirecting the file into the loop avoids a subshell so variables set inside persist.
Is it really free?
Yes. Every template on printsheet.io is completely free, with no sign-up, no account and no watermark. Generate as many sheets as you like.
How do I get an exact-scale print?
Choose your paper size, then in the print dialog set Scale to 100% or “Actual size” and Margins to None. The sheet is defined in real millimetres, so it prints at true size. Use the calibration ruler page to verify.
Which paper sizes are supported?
A4, A5, A3, A6, US Letter, Legal and Tabloid, in portrait or landscape. Pick the size that matches the paper loaded in your printer.
Can I save it as a PDF or image?
Yes — choose “Save as PDF” in the print dialog, or use the PNG and SVG download buttons. PDF and SVG keep the exact millimetre dimensions; PNG is a high-resolution 300 DPI image.