Living collection · BSH-001 to BSH-028
The tiny operators that live in every command line, one per page.
Brace and parameter expansion, heredocs, ghost variables, displacements: every insect gets its card, its label, and the answer to the question that matters — how to call it.
Drawers
The six drawers these insects are pinned in.
The whole specimen case
- BSH-001 {a,b} One word becomes two: the list in braces multiplies whatever surrounds it. Braces common
- BSH-002 {1..10} From one end to the other, the shell lines up the sequence — with a step, if asked. Braces common
- BSH-003 dir/{a,b,c} Nested braces and a shared prefix: a directory tree in one line. Braces uncommon
- BSH-004 ${var:-padrão} If the variable is empty, the default takes over — without touching the variable. Parameters common
- BSH-005 ${var:=padrão} Like :-, but the default gets written into the variable. Parameters uncommon
- BSH-006 ${var:?erro} No value, and the script stops right there — with the message you chose. Parameters forgotten
- BSH-007 ${var:+alterno} The default's opposite: it only produces a value when the variable has one. Parameters forgotten
- BSH-008 ${#var} The value's length, counted in characters, with no helper process. Parameters uncommon
- BSH-009 ${var#prefixo} It gnaws at the start of the value: # takes the smallest bite, ## the largest. Parameters uncommon
- BSH-010 ${var%sufixo} It gnaws at the end of the value: % takes the smallest bite, %% the largest. Parameters uncommon
- BSH-011 ${var/velho/novo} Swaps one piece of the value for another; with a double slash, all of them. Parameters common
- BSH-012 ${var^^} Raises or lowers the case of the whole value — or just the first letter. Parameters uncommon
- BSH-013 ${!var} The variable that points at another: it expands the name stored inside it. Parameters forgotten
- BSH-014 ${var:2:5} A slice of the value: it starts at the offset, measures the length. Parameters uncommon
- BSH-015 <(comando) A command's output dressed as a file — without touching the disk. Processes uncommon
- BSH-016 coproc A background process with two pipes wired to the shell. Processes forgotten
- BSH-017 << The text enters the command right there, up to the agreed word. Documents common
- BSH-018 <<< One word becomes the command's whole input: the pocket heredoc. Documents uncommon
- BSH-019 $_ The previous command's last argument, kept in an underscore. Ghost variables uncommon
- BSH-020 $? The last command's exit status: zero is good silence. Ghost variables common
- BSH-021 $$ The shell's own process number — the session's registration. Ghost variables common
- BSH-022 $! The PID of the last process sent to the background. Ghost variables uncommon
- BSH-023 $0 The name the script was called by — itself, on the label. Ghost variables common
- BSH-024 $- The shell's lit options, one letter per flag. Ghost variables forgotten
- BSH-025 $PIPESTATUS The exit status of every link in the pipe, not just the last. Ghost variables forgotten
- BSH-026 cd - Back to the previous directory — and it even announces where it went. Displacements common
- BSH-027 pushd A stack of directories: push on the way out, pop on the way back. Displacements uncommon
- BSH-028 shift Discards the first argument and pulls the queue one step forward. Displacements uncommon