Skip to content
Justice Tech School

Quoting

Double quotes allow variables, single quotes are literal and backslash escapes one character. Always quote variables.

Example
x="a b"
echo "$x" '$x' \$x
files="one two"
for f in $files; do echo "[$f]"; done
for f in "$files"; do echo "[$f]"; done

Result

a b $x $x
[one]
[two]
[one two]

Exercise

Prevent word splitting.

echo "x"

Quiz Test

Do single quotes expand variables?

These free lessons are for learning. Join a full course for projects, mentor feedback and a verified certificate.