shell-mastery — Metasyntactic

Metasyntactic Variables (foo bar baz bat)

Convention for placeholder names in programming and shell examples. Know these — they signal "this is a generic example, substitute your own values."

The canonical sequence
foo, bar, baz, qux, quux, quuz, corge, grault, garply, waldo, fred, plugh, xyzzy, thud
Origin
  • foo / bar — possibly from WWII military slang "FUBAR" (Fouled Up Beyond All Recognition)

  • baz — third variable, attributed to Stanford AI Lab

  • qux — fourth, from MIT

  • xyzzy — magic word from Colossal Cave Adventure (1976)

  • waldo — "Where’s Waldo?" — the thing you’re looking for

How they’re used in shell examples
# Variables
foo="hello"; bar="world"; echo "$foo $bar"

# Functions
foo() { echo "I am foo"; }
bar() { foo | tr a-z A-Z; }

# Files
touch foo.txt bar.txt baz.txt
for f in foo bar baz; do echo "processing $f"; done

# Hostnames in network examples
ssh foo.example.com
ping bar.internal
dig baz.test
The professional alternative (use in production docs)
# Instead of foo/bar, use descriptive names:
src_host="web-01.prod"
dst_host="db-01.prod"
backup_dir="/mnt/backup"
In competitions, they’ll use foo/bar/baz to test if you can read past the placeholders and focus on the command structure. Don’t get confused by the names — focus on the operators and pipes.