Recall & Review
beginner
What is a here document (<
A here document lets you send multiple lines of text or commands as input to a program or command directly within a script. It uses <
Click to reveal answer
beginner
How do you start and end a here document in bash?
You start with <
Click to reveal answer
intermediate
What happens if you quote the EOF marker in a here document?
If you quote EOF like <<'EOF', the text inside is treated literally. Variables and commands inside won’t be expanded or executed.
Click to reveal answer
beginner
Give a simple example of a here document that prints multiple lines using cat.
Example:
cat <
Click to reveal answer
beginner
Why are here documents useful in scripting?
They let you write multi-line input or scripts inside your script without needing extra files. This makes scripts cleaner and easier to manage.Click to reveal answer
What does <
✗ Incorrect
<
How do you correctly end a here document started with <
✗ Incorrect
The here document ends when the ending marker (EOF) appears alone on a line with no spaces or tabs.
What happens if you quote the EOF marker like <<'EOF'?
✗ Incorrect
Quoting EOF disables variable and command expansion inside the here document.
Which command commonly uses here documents to read multi-line input?
✗ Incorrect
cat can read multi-line input from a here document and print it.
Why use here documents instead of separate input files?
✗ Incorrect
Here documents keep multi-line input inside the script, making it easier to manage without extra files.
Explain how a here document works in bash scripting and give a simple example.
Think about how you send several lines to a command inside a script.
You got /4 concepts.
Describe the effect of quoting the EOF marker in a here document and why you might want to do that.
Consider when you want the text exactly as written.
You got /3 concepts.