Feed several lines to cat using a here-document.
Keep $HOME in the body literal instead of expanding it. Use Bash.
Which opening line is correct?
Quoting the here-document delimiter suppresses parameter expansion, command substitution, and arithmetic expansion in the body.
Detailed explanation
cat <<EOFIncorrect. An unquoted delimiter permits $HOME to expand in the body.
Incorrect. An unquoted delimiter permits $HOME to expand in the body.
cat < EOFIncorrect. < redirects from a file named EOF rather than starting a here-document.
Incorrect. < redirects from a file named EOF rather than starting a here-document.
cat <<<EOFIncorrect. <<< is a here-string for one word or string, not a multi-line here-document.
Incorrect. <<< is a here-string for one word or string, not a multi-line here-document.
cat <<'EOF'Correct. Quoting EOF keeps $HOME literal until the delimiter line.
Correct. Quoting EOF keeps $HOME literal until the delimiter line.
Try it yourself
An example you can run in a temporary verification environment.
cat <<'EOF'
path=$HOME
EOFExpected result
path=$HOMEKey points
- << starts a here-document
- A quoted delimiter suppresses expansion
- The body becomes standard input
Notes
- Environment: Bash 5.2
- 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.