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.
Incorrect. Unquoted $HOME expands to the variable value.
echo "$HOME"Incorrect. Double quotes still allow variable expansion.
Incorrect. Double quotes still allow variable expansion.
echo ${HOME}Incorrect. Braces clarify the variable name but still expand its value.
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.
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
- Command output formatting can vary slightly by distribution or tool version.
- Run the example in a temporary directory or process when possible.
Foundation review
Read the scope first
Check whether the command acts on the current shell, a new process, an existing process, or a file.
Verify the observable result
Use the supplied command and compare the output with the expected result.