expand Command

Purpose

Writes to standard output with tabs changed to spaces.

Syntax

expand [ -t TabList ] [ File ... ]

expand [-tabstop]|[-tab1,tab2,...,tabn] [File ...]

Description

The expand command writes the named files or standard input to standard output, and replaces the tab characters with one or more space characters. Any backspace characters are copied to the output and cause the column position count for tab stop calculations to decrement; the column position count will not decrement below zero.

Note: The File parameter must be a text file.

Flags

Item Description
-t TabList Specifies the position of the tab stops. The default value of a tab stop is 8 column positions.

The TabList variable must consist of a single positive-decimal integer or multiple positive-decimal integers. The multiple integers must be in ascending order, and must be separated by commas or by blank characters with quotation marks around the integers. The single TabList variable sets the tab stops an equal number of column positions apart. The multiple TabList variable sets the tab stops at column positions that correspond to the integers in the TabList variable.

If the expand command processes a tab stop beyond the last one specified in the TabList variable, the tab stop is replaced by a single-space character in the output.

Parameters

Item Description
tabstop Specified as a single argument. It sets tabstop SPACE characters apart instead of the default 8.
tab1, tab2,..., tabn Sets TAB characters at the columns specified by -tab1,tab2,...,tabn.

Exit Status

This command returns the following exit values:

Item Description
0 Successful completion.
>0 An error occurred.

Examples

  1. To adjust the tab stops an equidistance amount in text.fil, enter:
    expand -t 3 text.fil
    If text.fil contains:
    1       2        3456789
    then the expand command displays:
    1  2        3456789
  2. To adjust the tab stops a varied amount in text.fil, enter:
    expand -t 3,15,22  text.fil
    OR
    expand -t "3 15 22" text.fil
    If text.fil contains:
    1      2       3      456789
    then the expand command displays:
    1  2       3      456789

Files

Item Description
/usr/bin/expand Contains the expand command.