xref: /openbsd/usr.bin/expand/expand.1 (revision 3cab2bb3)
1.\"	$OpenBSD: expand.1,v 1.20 2014/03/17 21:48:51 jmc Exp $
2.\"	$NetBSD: expand.1,v 1.3 1995/09/02 06:19:45 jtc Exp $
3.\"
4.\" Copyright (c) 1980, 1990, 1993
5.\"	The Regents of the University of California.  All rights reserved.
6.\"
7.\" Redistribution and use in source and binary forms, with or without
8.\" modification, are permitted provided that the following conditions
9.\" are met:
10.\" 1. Redistributions of source code must retain the above copyright
11.\"    notice, this list of conditions and the following disclaimer.
12.\" 2. Redistributions in binary form must reproduce the above copyright
13.\"    notice, this list of conditions and the following disclaimer in the
14.\"    documentation and/or other materials provided with the distribution.
15.\" 3. Neither the name of the University nor the names of its contributors
16.\"    may be used to endorse or promote products derived from this software
17.\"    without specific prior written permission.
18.\"
19.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
20.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
23.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
24.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
25.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
26.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
27.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
28.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
29.\" SUCH DAMAGE.
30.\"
31.\"	@(#)expand.1	8.1 (Berkeley) 6/9/93
32.\"
33.Dd $Mdocdate: March 17 2014 $
34.Dt EXPAND 1
35.Os
36.Sh NAME
37.Nm expand ,
38.Nm unexpand
39.Nd expand tabs to spaces, and vice versa
40.Sh SYNOPSIS
41.Nm expand
42.Op Fl t Ar tablist
43.Op Ar
44.Nm unexpand
45.Op Fl a
46.Op Ar
47.Sh DESCRIPTION
48.Nm expand
49processes the named files or the standard input,
50writing the standard output with tabs changed into blanks.
51Backspace characters are preserved into the output and decrement
52the column count for tab calculations.
53.Nm expand
54is useful for pre-processing character files
55(before sorting, looking at specific columns, etc.) that
56contain tabs.
57.Pp
58.Nm unexpand
59puts tabs back into the data from the standard input or the named
60files and writes the result on the standard output.
61.Pp
62The options are as follows:
63.Bl -tag -width flag
64.It Fl a
65By default, only leading blanks and tabs
66are reconverted to maximal strings of tabs.
67If the
68.Fl a
69option is given, tabs are inserted whenever they would compress the
70resultant file by replacing two or more characters.
71.It Fl t Ar tablist
72If the argument to
73.Fl t ,
74.Ar tablist ,
75consists of a single numerical argument, tabs are set
76.Ar tablist
77spaces apart instead of the default 8.
78If multiple
79.Fl t
80options are given, then the tabs are set at those
81specific columns.
82.Pp
83Otherwise the argument to
84.Fl t
85may consist of a list
86of two or more positive decimal integers,
87separated by commas or single blank characters,
88in ascending order:
89in the event of having to process a
90.Aq tab
91at a position beyond the last of those specified in a multiple
92.Fl t
93list,
94the
95.Aq tab
96is replaced by a single
97.Aq space
98character.
99.Pp
100This implementation of
101.Nm
102additionally allows
103.Ar tablist
104to be specified without using the
105.Fl t
106flag, by prefixing
107.Ar tablist
108with a dash
109.Pq - .
110.El
111.Sh EXIT STATUS
112.Ex -std expand unexpand
113.Sh SEE ALSO
114.Xr fold 1
115.Sh STANDARDS
116The
117.Nm
118and
119.Nm unexpand
120utilities are compliant with the
121.St -p1003.1-2008
122specification,
123except that this implementation does not support a
124.Fl t
125flag for
126.Nm unexpand .
127.Pp
128The ability to specify tabstops without the
129.Fl t
130flag is not specified by
131.St -p1003.1-2008 ,
132though it states it
133.Dq may be present in some implementations .
134.Sh HISTORY
135The
136.Nm expand
137utility first appeared in
138.Bx 1 .
139