Skip to content

Create a file with EOF in Bash

In Bash, one can create and write to a file using the echo command. However, this method has some limitations when it comes to writing multiple lines of text. One way to overcome this limitation is by using the EOF (End Of File) command. In this blog post, we will discuss how to create and write to a file using the EOF command in Bash.

Create and write a file with EOF in sh

cat << EOF > target.file
text file
EOF

append text to a file

cat << EOF >> target.file
append text
EOF
Feedback