🐧 Linux / Shell Scripting
Beginner
What is the difference between single quotes and double quotes in bash?
Answer
Single quotes (') preserve the literal value of every character — no variable expansion, no command substitution, no escape sequences. Everything inside is treated as plain text. Double quotes (") allow variable expansion ($VAR), command substitution ($(cmd)), and some escape sequences (\n, \"). Example: echo '$HOME' prints $HOME literally, while echo "$HOME" prints /home/user. Always double-quote variables in scripts ("$var") to prevent word splitting and globbing on values with spaces or special characters.