maux
Star on GitHub Buy me a coffee

Manual / expand

expand(1)

EXPAND(1) General Commands Manual EXPAND(1)

expand - convert tabs to spaces

expand [ -t tablist ] [ file ] ...

Expand copies each named file (standard input if none is given) to standard output, replacing each tab with the spaces needed to reach the next tab stop.

Without -t, stops fall every 8 columns. -t N (a single number) sets stops every N columns instead, without limit — every tab in the file keeps expanding to the next multiple of N. -t list (two or more increasing numbers, comma- or blank-separated) sets stops at exactly those columns; once the column has passed the last one in list, each further tab becomes a single space.

A backspace is written to the output as itself and moves the column back by one (never below 0); a tab already exactly on a stop still advances to the next one, not zero columns. The column does not reset between operands — an unterminated file's trailing column carries into the next file's first tab.

/usr/man/EXPAND this page

unexpand(1), fold(1), cut(1)

Exit status is 0; 1 if a file named on the command line could not be opened — that file is skipped, a diagnostic naming it is written to standard error, and the remaining operands are still processed; 2 for a usage error, including a malformed or non-increasing tablist or a stop over 120.

An explicit tab stop is capped at 120 columns. The running column itself saturates at 250 rather than wrapping on a pathologically long unbroken line.

September 14, 2026 maux