Creating a text file with redirection from the keyboard

Used alone, the cat command uses whatever you type at the keyboard as input. You can redirect this input to a file.

Press Ctrl-D on a new line to signal the end of the text.
At the system prompt, type the following:
cat > filename
This is a test.