A zero-byte file or zero-length file is a
computer file
A computer file is a computer resource for recording data in a computer storage device, primarily identified by its file name. Just as words can be written to paper, so can data be written to a computer file. Files can be shared with and trans ...
containing no
data
In the pursuit of knowledge, data (; ) is a collection of discrete Value_(semiotics), values that convey information, describing quantity, qualitative property, quality, fact, statistics, other basic units of meaning, or simply sequences of sy ...
; that is, it has a length or size of zero bytes.
Creation
There are many ways that could manually create a zero-byte file, for example, saving empty content in a
text editor
A text editor is a type of computer program that edits plain text. Such programs are sometimes known as "notepad" software (e.g. Windows Notepad). Text editors are provided with operating systems and software development packages, and can be ...
, using
utilities
A public utility company (usually just utility) is an organization that maintains the infrastructure for a public service (often also providing a service using that infrastructure). Public utilities are subject to forms of public control and ...
provided by
operating systems, or programming to create it. On
Unix-like
A Unix-like (sometimes referred to as UN*X or *nix) operating system is one that behaves in a manner similar to a Unix system, although not necessarily conforming to or being certified to any version of the Single UNIX Specification. A Unix-li ...
systems, the shell command
$ touch
In physiology, the somatosensory system is the network of neural structures in the brain and body that produce the perception of touch ( haptic perception), as well as temperature ( thermoception), body position (proprioception), and pain. It ...
filename
results in a zero-byte file . Zero-byte files may arise in cases where a program creates a file but aborts or is interrupted prematurely while writing to it. Because writes are
cached in
memory
Memory is the faculty of the mind by which data or information is encoded, stored, and retrieved when needed. It is the retention of information over time for the purpose of influencing future action. If past events could not be remembered ...
and only flushed to disk at a later time (
page cache
In computing, a page cache, sometimes also called disk cache, is a transparent cache for the pages originating from a secondary storage device such as a hard disk drive (HDD) or a solid-state drive (SSD). The operating system keeps a page cache ...
), a program that does not flush its writes to disk or terminate normally may result in a zero-byte file. When the zero-byte file is made, file system does not record the file's content on storage, but only updates its index table.
Metadata
Even a file describing an empty
word processor
A word processor (WP) is a device or computer program that provides for input, editing, formatting, and output of text, often with some additional features.
Early word processors were stand-alone devices dedicated to the function, but current ...
document
A document is a written, drawn, presented, or memorialized representation of thought, often the manifestation of non-fictional, as well as fictional, content. The word originates from the Latin ''Documentum'', which denotes a "teaching" o ...
, an
image file
An Image file format is a file format for a digital image. There are many formats that can be used, such as JPEG, PNG, and GIF. Most formats up until 2022 were for storing 2D images, not 3D ones. The data stored in an image file format may be ...
with zero-by-zero dimensions, or an
audio file
An audio file format is a file format for storing digital audio data on a computer system. The bit layout of the audio data (excluding metadata) is called the audio coding format and can be uncompressed, or compressed to reduce the file size, o ...
of length zero seconds usually still contains
metadata identifying the
file format and describing some basic attributes of the file; it results in the file with some positive size. Some very simple formats do not use metadata, such as
ASCII
ASCII ( ), abbreviated from American Standard Code for Information Interchange, is a character encoding standard for electronic communication. ASCII codes represent text in computers, telecommunications equipment, and other devices. Because ...
text file
A text file (sometimes spelled textfile; an old alternative name is flatfile) is a kind of computer file that is structured as a sequence of lines of electronic text. A text file exists stored as data within a computer file system. In operat ...
s; these may validly be zero bytes (a common convention terminates text files with a one- or two-byte newline, however). Conversely, zero-byte files must use some disk space to be indexed by a
filesystem
In computing, file system or filesystem (often abbreviated to fs) is a method and data structure that the operating system uses to control how data is Computer data storage, stored and retrieved. Without a file system, data placed in a storage me ...
, though none for content.
Uses
Zero-byte files cannot be loaded or used by most applications. In some cases, zero-byte files may be used to convey information like file metadata (for example, its
filename may contain an instruction to a user viewing a directory listing such as , etc.); or to put in a directory to ensure that it is nonempty, since some tools such as backup and
revision control
In software engineering, version control (also known as revision control, source control, or source code management) is a class of systems responsible for managing changes to computer programs, documents, large web sites, or other collections o ...
software may ignore the empty directories.
IF Exist - Testing:
Use the zero-byte (zero length) file as an "exit" ramp or for a "goto" statement within a batch-file or script. It provides a directory listing, but requires no disk space.
IF EXIST C:\NOTHING.TXT EXIT
IF NOT EXIST C:\NOTHING.TXT GOTO START
:START
REM Create the zero-length file
C:\>type null>nothing.txt
:EXIT
References
Bibliography
*
Computer files
{{software-type-stub