A super-small command-line utility that creates an empty file with the specified name
Installation • Usage • Examples • Building from source
touch is a minimalist command-line tool that creates an empty file with a given name. If the file already exists, it reports an error and exits—no overwrites, no surprises. It's a simple, focused utility for scripts and everyday use.
Download the latest binary for your platform from the Releases page and place it somewhere in your PATH.
git clone https://github.com/ScavyXYZ/touch.git
cd touch
g++ -std=c++17 -o touch touch.cpptouch <filename>| Argument | Description |
|---|---|
<filename> |
Name of the file to create |
Create a new empty file:
touch notes.txtTry to create a file that already exists:
touch notes.txt
# Error: The file is already exist.Create a file in a subdirectory:
touch ./data/config.ini- A C++17 compiler (g++, clang++, or MSVC)
- CMake (optional, if you prefer a build system)
g++ -std=c++17 -o touch touch.cppThe classic Unix touch command updates timestamps and creates files, but its behavior can be surprising—it never fails, even when a file exists. This utility flips that: it only creates a file if it doesn't exist, and errors out otherwise. Perfect for scripts where you want to guarantee a fresh file or explicitly avoid overwriting existing data.