3 Ways to Create a .txt File in Mac Terminal

Terminal is already on your Mac — in Applications → Utilities or searchable via Spotlight with ⌘Space. Creating plain text files from Terminal is faster than any GUI once you know the commands, and it guarantees clean plain text every time with no hidden formatting.

Here are the three commands worth knowing, each useful in different situations.

Method 1: touch — create an empty file

touch ~/Desktop/notes.txt

touch creates an empty file at the path you give it. If the file already exists, it updates the timestamp but doesn't change the contents — useful to know so you don't accidentally wipe something.

You can create multiple files at once by listing them after the command:

touch ~/Desktop/notes.txt ~/Desktop/todo.txt ~/Desktop/draft.txt

After running this, open the file in any text editor and start writing. The file is genuinely empty — zero bytes, no formatting, no hidden characters.

Method 2: echo — create a file with content

echo "Meeting notes from Monday" > ~/Desktop/notes.txt

The > operator redirects the output of echo into a file. If the file doesn't exist, Terminal creates it. If it does exist, it overwrites it completely — so be careful with this one.

To add to an existing file without overwriting it, use >> instead:

echo "Another line of notes" >> ~/Desktop/notes.txt

This appends to the end of the file. Useful for building up a log or adding to a running list.

Method 3: cat — write multi-line content

cat > ~/Desktop/notes.txt

Run this command and Terminal will wait for your input. Type or paste as many lines as you want. When you're done, press Control+D on a new line to save and exit. Everything you typed goes into the file.

This is useful when you want to write a quick multi-line note without opening a text editor. It's not great for editing — you can't move the cursor around — but for capturing something quickly it works well.

All three methods create UTF-8 encoded plain text files. No rich text, no formatting, no metadata. What you type is exactly what goes into the file.

Navigating to the right folder first

If you want the file somewhere other than the Desktop, use cd to navigate first:

cd ~/Documents/Work
touch meeting-notes.txt

Or just include the full path in the command:

touch ~/Documents/Work/meeting-notes.txt

Opening the file after creating it

You can open the file from Terminal directly using the open command:

open ~/Desktop/notes.txt

macOS will open it in whatever app is set as default for .txt files — usually TextEdit. If you want to open it in a specific app like VS Code:

open -a "Visual Studio Code" ~/Desktop/notes.txt

Between these three commands you can handle pretty much any plain text file creation task from Terminal. touch for empty files, echo > for single-line content, cat > for multi-line input. All fast, all reliable, all genuinely plain text.