CMD Master
Back to Blog
Arnošt Havelka

Create empty files with touch

Make a new empty file, or update the timestamp on a file that already exists.

Start Interactive Lesson
Create empty files with touch

touch is the fastest way to create an empty file. If the name already exists, touch does not wipe the contents — it only refreshes the last-modified time. That second use is why scripts and build tools call it so often.

Create a new empty file

Give touch a name that is not there yet. The file appears immediately, with zero bytes.

Try the command

Create an empty file!

Build the command
touch
Terminal
C:\Users\User>touch empty.txt

Make a placeholder file:

Command Prompt
Documents
C:\Users\User>ls

You can pass several names in one command: touch a.txt b.txt c.txt.

Refresh a file that already exists

If existing.txt is already on disk, touch existing.txt keeps the text inside and only updates the timestamp. Use this when a process watches for “new” files, or when you want ls -l to show a current time without opening an editor.

touch existing.txt
ls -l existing.txt

touch will not create missing parent folders. If you need logs/today.txt and logs does not exist, create the folder with mkdir first.


Knowledge Check

1 / 3

What does touch empty.txt do when the file is missing?

References

These documentation links provide authoritative details for the commands used in this article.