78 / 80 · 12 Programming for QA · Bash Scripting for QA← prev⊞ allnext →☰ Read as one page
9.8Common Bash Reference
| Concept | Syntax | Why It Matters |
|---|---|---|
set -euo pipefail |
Script header | Catches errors instead of silently continuing |
$? |
Exit code of last command | Check if a tool succeeded before proceeding |
$! |
PID of last background process | Track and kill background servers |
${VAR:-default} |
Default value | Parameterize without requiring the variable |
command & |
Run in background | Start servers without blocking |
trap cleanup EXIT |
Run on exit | Guaranteed cleanup |
xargs -P N |
Parallel execution | Run repetitive tasks in parallel |
2>/dev/null |
Suppress stderr | Hide expected error messages |
| ` | true` |