Module 46 expandunexpand (BSD)

Previous Table of Contents Next


Module 46
expand/ unexpand (BSD)

DESCRIPTION

The external expand command expands tabs to spaces. The expand command reads the named files or the standard input, changes the tabs to the appropriate number of blanks, and writes the results on the standard output.

The external unexpand command replaces leading spaces and tabs with just tabs where possible.

COMMAND FORMAT

Following is the general format of the expand command.

 expand   [ -tabstop  -tab1,tab2,tab3,...,tabn ] [ file_list ]      unexpand [ -a ] [ file_list ] 

Options

The following options may be used to control how expand functions.

- tabstop Sets tab stops tabstop spaces apart.
- tab1,.,tabn Sets tabs at specific tab positions defined by tab1 through tabn.
-a Tabs are inserted at all occurrences that would replace two or more spaces. Without the -a option unexpand only replaces leading blanks and tabs.

Arguments

The following argument may be passed to the expand command.

file_list The list of files read and processed by expand . If no files are specified expand reads the standard input.

RELATED COMMANDS

Refer to the tabs command described in Module 130.

RELATED FILES

The expand command reads from standard input or files and writes to standard output.

APPLICATIONS

You use the expand command to convert tab characters to the appropriate number of spaces. You may find expand useful to preprocess character files that contain tabs before performing character processing on the files. For example, you may want to remove tabs before sorting or examining specific columns of a file.

TYPICAL OPERATION

In this activity you use the expand command to remove tabs from a file containing tab-separated columns. Begin at the shell prompt.

1.    Type cat -v -t file1 and press Return . Notice the ^I (tabs) embedded in the output.
2.    Type expand file1 cat -v -t and press Return . Notice the output has no tabs in it.
3.     Turn to Module 143 to continue the learning sequence.


Previous Table of Contents Next

Copyright Wordware Publishing, Inc.


Illustrated UNIX System V
Illustrated Unix System V/Bsd
ISBN: 1556221878
EAN: 2147483647
Year: N/A
Pages: 144
Authors: Robert Felps

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net