Search⌘ K
AI Features

Writing Multiple Lines to a File

Explore how to write multiple lines to a file in the command-line interface by using the cat command. Understand input methods including keyboard entry and heredoc delimiters, enabling file creation without a text editor. This lesson helps you manage file content efficiently and ensures you can verify your file edits using the CLI.

We can create files from program output, and we can create a new file with a line of text, but we can also create a new file with multiple lines of text right from the command line without opening a text editor.

The cat command

In Creating and Reading Files, we used the cat command to view the contents of files. The cat command reads the contents ...