# Bash techniques

A ThinkThen function is a shell command. It reads standard input, prints an answer, and sets an exit code. Each page here teaches one shell form with one real run.

## Techniques

- [Branch with if](/how-tos/bash/if/): decide --quiet prints nothing.

- [Route with case](/how-tos/bash/case/): choose --raw prints the bare label.

- [Handle not sure](/how-tos/bash/not-sure/): refund_code=$? names the exit code of decide.

- [Set a cut or a band](/how-tos/bash/threshold-band/): One number is a cut.

- [Loop over lines](/how-tos/bash/while-read/): while read hands each line to decide on its own.

- [Chain questions with pipes](/how-tos/bash/pipeline/): Two filters in a row keep the records that pass both questions.

- [Ask many files at once](/how-tos/bash/batches/): A function asks one question of one file.

- [Fail a build](/how-tos/bash/ci-gate/): filter finds the lines that hedge.

- [Keep one process for a step loop](/how-tos/bash/long-lived-loop/): coproc holds one choose process open.

- [Judge one paragraph at a time](/how-tos/bash/judge-paragraphs/): awk -v RS= splits on blank lines.

- [Guard a coding agent tool call](/how-tos/bash/agent-tool-guard/): This Claude Code PreToolUse hook reads a proposed Bash command as text.

## Recipes

- [Label a JSON file and keep its ids](/how-tos/bash/label-a-json-file/): Label every ticket in a JSON array by kind and urgency.

- [Review a diff by what it does](/how-tos/bash/review-a-diff-by-what-it-does/): jq cuts a unified diff into hunks.

- [Lint prose for hedging](/how-tos/bash/lint-prose-for-hedging/): jq numbers the lines.

- [Fill a form by selection](/how-tos/bash/fill-a-form-by-selection/): Every field is a pick from a list you wrote, or true or false.

- [Set bad records aside first](/how-tos/bash/set-aside-bad-records/): jq reads each raw line and keeps only JSON objects with a string body.

On GitHub: [github.com/botassembly/thinkthen](https://github.com/botassembly/thinkthen)
