Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to create a here document that outputs "Hello World".
Bash Scripting
cat <<[1]
Hello World
EOF Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using different words after << and at the end.
Forgetting to put the ending delimiter.
✗ Incorrect
The delimiter after << must match the ending delimiter exactly. "EOF" is the common choice.
2fill in blank
mediumComplete the code to assign a multi-line string to a variable using a here document.
Bash Scripting
myvar=$(cat <<[1] Line 1 Line 2 EOF )
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using different delimiters at start and end.
Not using command substitution to assign the string.
✗ Incorrect
The delimiter after << must match the ending delimiter. "EOF" is commonly used.
3fill in blank
hardFix the error in the here document that should print a variable's value.
Bash Scripting
name="Alice" echo <<[1] Hello $name EOF
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using quotes around EOF which disables variable expansion.
Not using <<- when indenting the delimiter.
✗ Incorrect
Using <<-EOF allows tab-indented delimiters and preserves variable expansion.
4fill in blank
hardFill both blanks to create a here document that does NOT expand variables.
Bash Scripting
cat <<[1] The value is $value [2]
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using unquoted EOF which expands variables.
Mixing quoted and unquoted delimiters.
✗ Incorrect
Quoting the delimiter (like 'EOF') disables variable expansion inside the here document.
5fill in blank
hardFill all three blanks to create a here document that strips leading tabs and expands variables.
Bash Scripting
cat <<[1] Line 1 Value: $[2] [3]
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Quoting EOF which disables variable expansion.
Using wrong variable name inside the here document.
✗ Incorrect
Using <<-EOF with tabs before lines and matching EOF delimiter strips leading tabs and expands variables.