Skip to content

Latest commit

 

History

4 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 

Repository files navigation

touch

A super-small command-line utility that creates an empty file with the specified name

C++ License

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.

Installation

Pre-built binary

Download the latest binary for your platform from the Releases page and place it somewhere in your PATH.

Build from source

git clone https://github.com/ScavyXYZ/touch.git
cd touch
g++ -std=c++17 -o touch touch.cpp

Usage

touch <filename>
Argument Description
<filename> Name of the file to create

Examples

Create a new empty file:

touch notes.txt

Try 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

Building from source

Prerequisites

  • A C++17 compiler (g++, clang++, or MSVC)
  • CMake (optional, if you prefer a build system)

Using g++

g++ -std=c++17 -o touch touch.cpp

Why this exists

The 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.

About

A super-small command-line utility that creates an empty file with the specified name

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages