LinuxCommandLibrary

false

Return an unsuccessful (false) exit status

TLDR

Return a non-zero exit code

$ false
copy

Make a command always exit with 1
$ [command] && false
copy

SYNOPSIS

false [ignored command line arguments]
or: false OPTION

PARAMETERS

--help
    display this help and exit

--version
    output version information and exit

DESCRIPTION

The false command is a minimal utility that performs no operations and always terminates with a non-zero exit status of 1, indicating failure. It is essential in shell scripting for simulating a failing condition in control structures like if, while, or logical operators such as && and ||. For example, if false; then echo 'never printed'; fi skips the body.

Any command-line arguments provided to false are completely ignored, making it a pure no-op with predictable behavior. This contrasts with true, which succeeds with exit status 0. As part of the GNU coreutils package, false is highly portable, POSIX-compliant, and available on virtually all Unix-like systems.

Common uses include testing script logic, creating conditional fallbacks, or serving as a placeholder in makefiles and automation scripts. Its simplicity ensures reliability in high-performance or embedded environments where unnecessary computation must be avoided.

CAVEATS

Always exits with status 1 regardless of arguments or options (except --help and --version, which exit successfully). Arguments are ignored.

EXIT STATUS

Always 1 (failure), unless --help or --version is used (0 for success).

HISTORY

Introduced in early Unix systems as part of the Fourth Berkeley Software Distribution (4BSD). Standardized in POSIX.1-2001 and maintained in GNU coreutils since 1990s, with minimal changes due to its simplicity.

SEE ALSO

true(1)

Copied to clipboard