Workspace

Bash

terminal automation deployment and file workflows

Definition first

What Bash means

Bash is a programming language for writing exact instructions, often used for terminal automation deployment and file workflows. Start with one mental model: input goes through steps and becomes output.

Minimum run factsFile script.shRun bash script.shHabit Echo variables and use set flags before touching many files
Program

An ordered set of instructions. It reads input, follows rules, and produces output.

Value and variable

A value is data. A variable is the name you use to hold and reuse that data.

Function

A named piece of work. It takes input, does one job, and can return a result.

Runtime

POSIX shell compatible terminal is the place that actually runs code from script.sh.

First readable code

Commands

pwd ls cd echo
name="Ada"
echo "$name"
Output Ada

Language lineage

Bash family tree

See where Bash comes from, which languages feel close, and what to learn next.

roots
shUnixawk
currentBashUnix shell family
familyUnix shell family
best used for

terminal automation, deployment scripts, and file workflows

Zero base path

1Read one rule2Predict output3Type from memory4Run checklist5Repeat with one change

Question bank

Search before practice

Pick a stage or search across the open programming bank. Jump straight to the matching drill.

18 matching questions
Q 1ChoiceStage 1 definitions

Bash practice 1

Bash question 1. Choose the statement that matches echo output.

Q 2ChoiceStage 1 definitions

Bash practice 2

Bash question 2. Choose the statement that matches variable assignment.

Q 3ChoiceStage 1 definitions

Bash practice 3

Bash question 3. Choose the statement that matches pipe.

Q 4ChoiceStage 1 definitions

Bash practice 4

Bash question 4. Choose the statement that matches for loop.

Q 5ChoiceStage 1 definitions

Bash practice 5

Bash question 5. Choose the statement that matches echo output.

Q 6ChoiceStage 1 definitions

Bash practice 6

Bash question 6. Choose the statement that matches variable assignment.

Q 7ChoiceStage 1 definitions

Bash practice 7

Bash question 7. Choose the statement that matches pipe.

Q 8ChoiceStage 1 definitions

Bash practice 8

Bash question 8. Choose the statement that matches for loop.

Q 9ChoiceStage 1 definitions

Bash practice 9

Bash question 9. Choose the statement that matches echo output.

Q 10ChoiceStage 1 definitions

Bash practice 10

Bash question 10. Choose the statement that matches variable assignment.

Q 11ChoiceStage 1 definitions

Bash practice 11

Bash question 11. Choose the statement that matches pipe.

Q 12ChoiceStage 1 definitions

Bash practice 12

Bash question 12. Choose the statement that matches for loop.

Q 13ChoiceStage 1 definitions

Bash practice 13

Bash question 13. Choose the statement that matches echo output.

Q 14ChoiceStage 1 definitions

Bash practice 14

Bash question 14. Choose the statement that matches variable assignment.

Q 15ChoiceStage 1 definitions

Bash practice 15

Bash question 15. Choose the statement that matches pipe.

Q 16ChoiceStage 1 definitions

Bash practice 16

Bash question 16. Choose the statement that matches for loop.

Q 17ChoiceStage 1 definitions

Bash practice 17

Bash question 17. Choose the statement that matches echo output.

Q 18ChoiceStage 1 definitions

Bash practice 18

Bash question 18. Choose the statement that matches variable assignment.

Multiple choice

Bash practice 1

Q 1Choicenew

Bash question 1. Choose the statement that matches echo output.

echo "$name"

Reference

Patterns for script.sh

POSIX shell compatible terminalbash script.sh
Recall from memoryRead a small point then write it back without looking
Trace the codeWrite variable values line by line before you run the answer
Type it yourselfCopy less type more and fix one small error at a time

pwd ls cd echo

Commands

name="Ada"
echo "$name"
  • Quote variables
  • Start with echo
  • Run in a small folder first

grep sort uniq wc

Pipes

printf "a\na\nb\n" | sort | uniq
  • Pipe output to the next command
  • Use rg or grep for search
  • Count with wc

shebang variables if loops

Scripts

for file in *.txt; do
  echo "$file"
done
  • Use set -e for safer scripts
  • Quote paths
  • Dry run before deleting