A classic use of here documents is to create a file by typing its content:
cat > fruits.txt << EOF apple orange lemon EOF
The here-document is the lines between the
<< EOF and
This here document becomes the input of the
cat command simply outputs its input,
and using the output redirection operator
> we redirect to a file
As a result, the
fruits.txt file will contain the lines:
apple orange lemon
The usual rules of output redirection apply:
fruits.txt did not exist before, it will be created.
If it existed before, it will be truncated.