Home / Code typing practice / Bash

Free code typing practice

Bash Typing Practice

Free Bash typing practice: type real shell commands with pipes, redirects, $variables, quotes and test brackets. Get faster and more accurate in the terminal.

The terminal is where a typo hurts most: a wrong character in a command can delete the wrong file. Bash uses pipes |, redirects > and >&2, $VARIABLES, quotes and [ ] tests, often all on one line.

The snippets cover for loops, if tests, grep piped into wc, PATH exports and find with -exec, the commands developers and DevOps engineers type daily.

Bash code you will type

Each session picks from these, in random order. Line breaks are shown as single spaces.

for f in *.log; do gzip "$f"; done
if [ -z "$NAME" ]; then echo "NAME is not set" >&2; exit 1; fi
grep -rn "TODO" src/ | wc -l
export PATH="$HOME/bin:$PATH"
find . -name '*.tmp' -mtime +7 -exec rm {} \;

Symbols to watch

|$">&[ ]-~

Not sure which finger to use? See the programming symbols finger chart.

Tips for typing Bash faster

  • Pipe | is Shift and backslash: right little finger. Keep a space either side as you type.
  • Quote variables as you type them: "$f" instead of $f avoids bugs with spaces in file names.
  • Flags start with - or --: hyphen with your right little finger, then straight back to the letters.

Frequently asked questions

Why practise typing shell commands?

Command lines are dense with symbols and unforgiving of typos. Accurate typing makes the terminal faster and safer.

Does Bash practice help with Linux and DevOps work?

Yes. Pipes, redirects, quoting and variables are the same in scripts, CI pipelines and Dockerfiles.

Practise typing other languages

All code typing practice