Format
- expand [–B]
[–t tablist] [-W option[,option]...] [file …file …]
- expand [–tabstop]
[–tab1,tab2,...,tabn]
[–B] [-W option[,option]...] [file …file …]
Description
expand reads
text input from the files that are specified on the command line,
converts tabs into spaces, and writes the result to the standard output
(stdout). If you do not specify any files on
the command line, expand reads from the
standard input (stdin).
expand preserves
backspace characters. By default, tab stops are set every eight columns.
A tab after the last tabstop is replaced by a space.
Options
The first syntax of
expand supports
the following options:
- –B
- Disables the automatic conversion of tagged files. This option
is ignored if the filecodeset or pgmcodeset options
(-W option) are specified.
- –t tablist
- Sets tab stops at positions that are indicated by tablist.
Numbers in tablist must be in ascending
order (origin 0) and separated by commas or blanks; however, the list
must be one argument so you need shell quoting if you are using blanks.
The list can consist of a single number, in which case tabs are set
every tablist positions apart.
- -W option[,option]...
- Specifies z/OS-specific options. The option keywords are case-sensitive. Possible
options are:
- filecodeset=codeset
- Performs text conversion from one code set to another when reading
from the file. The coded character set of the file is codeset. codeset can
be a code set name that is known to the system or a numeric coded
character set identifier (CCSID). Note that the command iconv
-l lists existing CCSIDs along with their corresponding code
set names. The filecodeset and pgmcodeset options
can be used on files with any file tag.
If pgmcodeset is
specified but filecodeset is omitted, then
the default file code set is ISO8859-1 even if the file is tagged
with a different code set. If neither filecodeset nor pgmcodeset is
specified, text conversion will not occur unless automatic conversion
is enabled or the _TEXT_CONV environment variable indicates text conversion.
For more information about text conversion, see Controlling text conversion for z/OS UNIX shell commands.
If filecodeset or pgmcodeset is
specified, then automatic conversion is disabled for this command
invocation and the -B option is ignored
if it is also specified. See z/OS UNIX System Services Planning for
more information about automatic conversion.
Restriction: The
only supported values for filecodeset are
ISO8859-1 and 819.
- pgmcodeset=codeset
- Performs text conversion from one code set to another when reading
from the file. The coded character set of the program (command) is codeset. codeset can
be a code set name that is known to the system or a numeric coded
character set identifier (CCSID). Note that the command iconv
-l lists existing CCSIDs along with their corresponding code
set names. The filecodeset and pgmcodeset options
can be used on files with any file tag.
If filecodeset is
specified but pgmcodeset is omitted, then
the default program code set is IBM-1047. If neither filecodeset nor pgmcodeset is
specified, text conversion will not occur unless automatic conversion
is enabled or the _TEXT_CONV environment variable indicates text conversion.
For more information about text conversion, see Controlling text conversion for z/OS UNIX shell commands.
If filecodeset or pgmcodeset is
specified, then automatic conversion is disabled for this command
invocation and the -B option is ignored
if it is also specified. See z/OS UNIX System Services Planning for
more information about automatic conversion.
Restriction: The
only supported values for pgmcodeset are
IBM-1047 and 1047.
The second syntax of
expand (which
the POSIX standard considers obsolete) supports the following options:
- –tabstop
- Sets tab stops every tabstop columns.
- ––tab1,tab2,...,tabn
- Sets tab stops at each column tab1,tab2 and
so on (origin 0).
Examples
- To convert tabs in a text file to spaces that are 10 positions
apart:
expand -t 10 myTextFile
- To convert tabs in a text file containing ASCII characters to
spaces, assuming that
- The text file is untagged and you do not want to tag it or enable
automatic conversion, and
- You cannot alter the tag (for example, you are displaying an untagged
public text file or a read-only text file)
then issue: expand -W filecodeset=ISO8859-1,pgmcodeset=IBM-1047 myAsciiFile
- To convert tabs in a text file containing EBCDIC characters to
spaces, assuming that automatic conversion has been enabled but the
text file is incorrectly tagged as UTF-8:
expand -B myTextFile
Localization
expand uses
the following localization environment variables:
- LANG
- LC_ALL
- LC_CTYPE
- LC_MESSAGES
- NLSPATH
See Localization for more
information.
Environment variables
expand uses
the following environment variable:
- _TEXT_CONV
- Contains text conversion information for the command. The text
conversion information is not used when either the -B option
or the filecodeset or pgmcodeset option
(-W option) is specified. For more information
about text conversion, see Controlling text conversion for z/OS UNIX shell commands.
Exit values
- 0
- Successful completion
- 1
- Failure due to any of the following:
- Cannot open the input file
- Insufficient memory
- Incorrect tab stop specification
- The code set is not valid
- Could not turn off automatic conversion
- Could not perform requested text conversion
Portability
POSIX.2 User Portability Extension, X/Open Portability Guide, 4.2BSD and
higher.
The –B and -W options
are extensions of the POSIX standard.
Related information
pr, unexpand