Bash Create File

touch creates empty files instantly and updates a file's timestamp without touching its contents, making it the go-to command for quickly scaffolding new files.

Creating an Empty File

touch's primary job is to create a file if it doesn't already exist. Run it with a filename and bash instantly creates an empty, zero-byte file at that path — no editor required.

Create a new empty file

$ touch readme.txt
$ ls -l readme.txt
-rw-r--r-- 1 user user 0 Jul 16 10:00 readme.txt

Creating Several Files at Once

Pass multiple filenames in one command and touch creates every one of them. This is a quick way to scaffold a set of files, such as the pieces of a new project, before you start editing them.

Scaffold a handful of files

$ touch index.html style.css script.js
$ ls
index.html  script.js  style.css

Updating Timestamps on Existing Files

If the file already exists, touch does not erase or change its content — it only updates the file's last-modified and last-accessed timestamps to the current time. This is useful for triggering tools that watch for changed files, or for testing scripts that sort by modification date.

Bump a file's timestamp

$ touch readme.txt
$ stat -c '%y' readme.txt
2026-07-16 10:03:47.000000000 +0530
  • touch file — create an empty file, or update its timestamp if it already exists
  • touch a.txt b.txt c.txt — create several files at once
  • touch -t 202601011200 file — set a specific timestamp
  • touch -r other.txt file — copy other.txt's timestamp onto file
  • touch -c file — update the timestamp only if the file exists, never create it
FlagMeaning
-aChange only the last-accessed time
-mChange only the last-modified time
-cDon't create the file if it doesn't exist
-t STAMPSet a specific timestamp instead of using now
Note: Because touch never overwrites existing content, running it on a file you already have is completely safe — it's one of the few file commands with no destructive side effect.