Variables & quoting in Bash
Assignment, expansion, and the quoting that keeps words whole.
# assignment has no spaces; quoting decides how a value expands
name="Ada Lovelace"
count=3
echo "double quotes expand: $name typed $count runs"
echo 'single quotes do not: $name'
# always quote expansions: unquoted, the space would split the word
greeting="hello, ${name}"
echo "$greeting"
How it works
- Assignment has no spaces around
=; that rule is absolute. - Double quotes expand
$name; single quotes keep it literal. - Quoting expansions stops the shell splitting on the space.
Keywords and builtins used here
echo
The run, in numbers
- Lines
- 10
- Characters to type
- 292
- Tokens
- 30
- Three-star pace
- 90 tpm
At the three-star pace of 90 tokens a minute, this run takes about 20 seconds.
Step 1 of 3 in Variables & quoting, step 1 of 26 in Language basics.