Skip to main content

touch: Creating Files

touch is the fastest way to create an empty file from the command line. If the file already exists, it updates its timestamp without changing its contents.

Basic usage

touch report.txt

After running this, report.txt exists as an empty file. Confirm with:

ls -l report.txt

Creating multiple files at once

touch file1.txt file2.txt file3.txt

All three are created in a single command.

Naming conventions

PatternUsed for
lowercase.txtPlain text files
my-report.csvCSV data files
setup.shShell scripts
.envHidden config files

Avoid spaces in filenames. Use - or _ instead.

Common use cases

Creating placeholder files before filling them:

touch README.md requirements.txt .gitignore

Resetting a file's timestamp (useful in build systems):

touch existing-file.txt

Practice

Create a file called report.txt in your home directory.

Loading terminal…
Donate to this project