Variables and quoting
Updated July 3, 2026
A variable in bash is a name that stands for some text. Assignment has no spaces around the =.
name=alice
n=$(wc -l < ~/data/words.txt)
echo "$name: $n"$(...) is command substitution: bash runs the command inside and inserts its output as text.
Double quotes "$n" keep the value as one piece. Without quotes bash splits the value on spaces and expands patterns like *, which is a common source of bugs.
Used in
You need this in the lesson Bash: writing scripts.