Quoting Rules
In this page:
Quoting Rules
Double quotes ("...") allow variable expansion and command substitution inside them, while single quotes ('...') treat everything literally, including $. Unquoted variables get word-split and glob-expanded by the shell, which can cause bugs with spaces in values. Quoting variables consistently is one of the most important Bash habits.
Note: Always quote variables you expand, like "$name", unless you specifically want word-splitting.
Example: Quoting Rules
#!/bin/bash
name="Bob Smith"
echo "Double quotes: $name"
echo 'Single quotes: $name'
echo Unquoted: $name
Login to try C/C++/Java/PHP code in the editor
🔒
Chapter Quiz — Complete all 13 topics to unlock
0/13 topics done
Complete these topics first: