else
Fallback branch in shell conditional statements
TLDR
SYNOPSIS
if condition; then commands; else commands; fi
DESCRIPTION
else is a shell keyword providing an alternative branch in conditional statements. It executes when the preceding if (and any elif) conditions are false.else appears after if/elif blocks and before fi. It cannot have a condition - it catches all remaining cases. Only one else block is allowed per if statement.This is a fundamental shell scripting construct for handling the "otherwise" case in conditional logic.
CAVEATS
else is a shell reserved word, not a program, so it cannot be used outside an if block. Unlike if and elif it takes no condition and no then, and only one else may appear per if statement, always as the last branch before fi. A `case` statement has no else: its catch-all is the `*)` pattern.
HISTORY
else is part of POSIX shell syntax from the Bourne shell, created by Stephen Bourne at Bell Labs. It provides the standard fallback mechanism in shell conditional statements.