Here Documents (<<EOF)
In this page:
Here Documents (<<EOF)
A here document lets you feed multiple lines of literal text to a command's standard input, starting with <<EOF and ending at a line containing just the matching delimiter (EOF by convention, but any word works). Variables inside are expanded unless the delimiter is quoted, like <<EOF. Here documents are commonly used to write multi-line text into a file without many separate echo calls.
Note: Quote the delimiter, <<EOF, to prevent variable expansion inside the here document.
Example: Here Documents (<<EOF)
#!/bin/bash
name="World"
cat <<EOF
Hello, $name!
This is a multi-line
here document.
EOF
Login to try C/C++/Java/PHP code in the editor
Chapter Quiz — Complete all 14 topics to unlock
0/14 topics done
Complete these topics first: