[Bash] Why shell variable expansions need double quotes

Created on November 30, 2026

An unquoted expansion can be split into multiple arguments. Here, hello world becomes two arguments to printf.

value="hello world"
printf '<%s>\n' $value
<hello>
<world>

With double quotes, the complete value is passed as one argument.

value="hello world"
printf '<%s>\n' "$value"
<hello world>

Use "$value" when passing a variable as one argument to prevent word splitting and pathname expansion.

Bash