HOME is defined in the current shell.
Print the text $HOME literally instead of expanding the variable.
Which command is appropriate?
Inside single quotes, the dollar sign is treated as literal text and variable expansion does not occur.
Detailed explanation
echo $HOMEIncorrect. Unquoted $HOME expands to the variable value.
echo "$HOME"Incorrect. Double quotes still allow variable expansion.
echo ${HOME}Incorrect. Braces clarify the variable name but still expand its value.
echo '$HOME'Correct. Single quotes suppress the special meaning of $ and pass the literal text.
Try it yourself
An example you can run in a temporary verification environment.
HOME=/example; echo '$HOME'Expected result
$HOMEKey points
- Single quotes suppress expansion
- Double quotes expand variables
- Braces still perform expansion
Notes
- Environment: Bash 5.x / echo builtin
- Use disposable shell sessions and harmless commands for experiments.
- Shell behavior can depend on Bash options and distribution defaults.
Foundation review
Place the operation
Single quotes are the strongest simple quote for displaying a dollar expression literally.
Check the side effect
Compare a single-quoted, double-quoted, and unquoted expansion with printf.