1 .\"
   2 .\" Sun Microsystems, Inc. gratefully acknowledges The Open Group for
   3 .\" permission to reproduce portions of its copyrighted documentation.
   4 .\" Original documentation from The Open Group can be obtained online at
   5 .\" http://www.opengroup.org/bookstore/.
   6 .\"
   7 .\" The Institute of Electrical and Electronics Engineers and The Open
   8 .\" Group, have given us permission to reprint portions of their
   9 .\" documentation.
  10 .\"
  11 .\" In the following statement, the phrase ``this text'' refers to portions
  12 .\" of the system documentation.
  13 .\"
  14 .\" Portions of this text are reprinted and reproduced in electronic form
  15 .\" in the SunOS Reference Manual, from IEEE Std 1003.1, 2004 Edition,
  16 .\" Standard for Information Technology -- Portable Operating System
  17 .\" Interface (POSIX), The Open Group Base Specifications Issue 6,
  18 .\" Copyright (C) 2001-2004 by the Institute of Electrical and Electronics
  19 .\" Engineers, Inc and The Open Group.  In the event of any discrepancy
  20 .\" between these versions and the original IEEE and The Open Group
  21 .\" Standard, the original IEEE and The Open Group Standard is the referee
  22 .\" document.  The original Standard can be obtained online at
  23 .\" http://www.opengroup.org/unix/online.html.
  24 .\"
  25 .\" This notice shall appear on any product containing this material.
  26 .\"
  27 .\" The contents of this file are subject to the terms of the
  28 .\" Common Development and Distribution License (the "License").
  29 .\" You may not use this file except in compliance with the License.
  30 .\"
  31 .\" You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
  32 .\" or http://www.opensolaris.org/os/licensing.
  33 .\" See the License for the specific language governing permissions
  34 .\" and limitations under the License.
  35 .\"
  36 .\" When distributing Covered Code, include this CDDL HEADER in each
  37 .\" file and include the License file at usr/src/OPENSOLARIS.LICENSE.
  38 .\" If applicable, add the following below this CDDL HEADER, with the
  39 .\" fields enclosed by brackets "[]" replaced with your own identifying
  40 .\" information: Portions Copyright [yyyy] [name of copyright owner]
  41 .\"
  42 .\"
  43 .\" Copyright (c) 1992, X/Open Company Limited.  All Rights Reserved.
  44 .\" Portions Copyright (c) 1995, Sun Microsystems, Inc.  All Rights Reserved.
  45 .\"
  46 .TH EXPAND 1 "Feb 1, 1995"
  47 .SH NAME
  48 expand, unexpand \- expand TAB characters to SPACE characters, and vice versa
  49 .SH SYNOPSIS
  50 .LP
  51 .nf
  52 \fBexpand\fR [\fB-t\fR \fItablist\fR] [\fIfile\fR]...
  53 .fi
  54 
  55 .LP
  56 .nf
  57 \fBexpand\fR [\fB-\fItabstop\fR\fR] [\fB-\fItab1,\fR\fR \fItab2,.\fR \fI\&.\fR \fI\&.,\fR \fItabn\fR] [\fIfile\fR]...
  58 .fi
  59 
  60 .LP
  61 .nf
  62 \fBunexpand\fR [\fB-a\fR] [\fB-t\fR \fItablist\fR] [\fIfile\fR]...
  63 .fi
  64 
  65 .SH DESCRIPTION
  66 .LP
  67 The \fBexpand\fR utility copies \fIfile\fRs (or the standard input) to the
  68 standard output, with TAB characters expanded to SPACE characters. BACKSPACE
  69 characters are preserved into the output and decrement the column count for TAB
  70 calculations. \fBexpand\fR is useful for pre-processing character files (before
  71 sorting, looking at specific columns, and so forth) that contain TAB
  72 characters.
  73 .sp
  74 .LP
  75 \fBunexpand\fR copies \fIfile\fRs (or the standard input) to the standard
  76 output, putting TAB characters back into the data. By default, only leading
  77 SPACE and TAB characters are converted to strings of tabs, but this can be
  78 overridden by the \fB-a\fR option (see the OPTIONS section below).
  79 .SH OPTIONS
  80 .LP
  81 The following options are supported for \fBexpand\fR:
  82 .sp
  83 .ne 2
  84 .na
  85 \fB\fB-t\fR \fItablist\fR \fR
  86 .ad
  87 .RS 26n
  88 Specifies the tab stops. The argument \fItablist\fR must consist of a single
  89 positive decimal integer or multiple positive decimal integers, separated by
  90 blank characters or commas, in ascending order. If a single number is given,
  91 tabs will be set \fItablist\fR column positions apart instead of the default
  92 \fB8\fR. If multiple numbers are given, the tabs will be set at those specific
  93 column positions.
  94 .sp
  95 Each tab-stop position \fIN\fR must be an integer value greater than zero, and
  96 the list must be in strictly ascending order. This is taken to mean that, from
  97 the start of a line of output, tabbing to position \fIN\fR causes the next
  98 character output to be in the (\fIN\fR+1)th column position on that line.
  99 .sp
 100 In the event of \fBexpand\fR having to process a tab character at a position
 101 beyond the last of those specified in a multiple tab-stop list, the tab
 102 character is replaced by a single space character in the output.
 103 .RE
 104 
 105 .sp
 106 .ne 2
 107 .na
 108 \fB\fB-\fR\fItabstop\fR \fR
 109 .ad
 110 .RS 26n
 111 Specifies as a single argument, sets TAB characters \fItabstop\fR SPACE
 112 characters apart instead of the default \fB8\fR.
 113 .RE
 114 
 115 .sp
 116 .ne 2
 117 .na
 118 \fB\fB-\fR\fItab1\fR\fI,\|tab2,...,tabn\fR \fR
 119 .ad
 120 .RS 26n
 121 Sets TAB characters at the columns specified by
 122 \fB-\fR\fItab1,tab2,...,\|tabn\fR
 123 .RE
 124 
 125 .sp
 126 .LP
 127 The following options are supported for \fBunexpand\fR:
 128 .sp
 129 .ne 2
 130 .na
 131 \fB\fB-a\fR \fR
 132 .ad
 133 .RS 15n
 134 Inserts TAB characters when replacing a run of two or more SPACE characters
 135 would produce a smaller output file.
 136 .RE
 137 
 138 .sp
 139 .ne 2
 140 .na
 141 \fB\fB-t\fR \fItablist\fR \fR
 142 .ad
 143 .RS 15n
 144 Specifies the tab stops. The option-argument \fItablist\fR must be a single
 145 argument consisting of a single positive decimal integer or multiple positive
 146 decimal integers, separated by blank characters or commas, in ascending order.
 147 If a single number is given, tabs will be set \fItablist\fR column positions
 148 apart instead of the default \fB8\fR. If multiple numbers are given, the tabs
 149 will be set at those specific column positions. Each tab-stop position \fIN\fR
 150 must be an integer value greater than zero, and the list must be in strictly
 151 ascending order. This is taken to mean that, from the start of a line of
 152 output, tabbing to position \fIN\fR will cause the next character output to be
 153 in the (\fIN\fR+1)th column position on that line. When the \fB-t\fR option is
 154 not specified, the default is the equivalent of specifying \fB-t\fR \fB8\fR
 155 (except for the interaction with \fB-a\fR, described below).
 156 .sp
 157 No space-to-tab character conversions occur for characters at positions beyond
 158 the last of those specified in a multiple tab-stop list.
 159 .sp
 160 When \fB-t\fR is specified, the presence or absence of the \fB-a\fR option is
 161 ignored; conversion will not be limited to the processing of leading blank
 162 characters.
 163 .RE
 164 
 165 .SH OPERANDS
 166 .LP
 167 The following operand is supported for \fBexpand\fR and \fBunexpand\fR:
 168 .sp
 169 .ne 2
 170 .na
 171 \fB\fB\fIfile\fR\fR \fR
 172 .ad
 173 .RS 9n
 174 The path name of a text file to be used as input.
 175 .RE
 176 
 177 .SH ENVIRONMENT VARIABLES
 178 .LP
 179 See \fBenviron\fR(5) for descriptions of the following environment variables
 180 that affect the execution of \fBexpand\fR and \fBunexpand\fR: \fBLANG\fR,
 181 \fBLC_ALL\fR, \fBLC_CTYPE\fR, \fBLC_MESSAGES\fR, and \fBNLSPATH\fR.
 182 .SH EXIT STATUS
 183 .LP
 184 The following exit values are returned:
 185 .sp
 186 .ne 2
 187 .na
 188 \fB\fB0\fR \fR
 189 .ad
 190 .RS 7n
 191 Successful completion
 192 .RE
 193 
 194 .sp
 195 .ne 2
 196 .na
 197 \fB\fB>0\fR \fR
 198 .ad
 199 .RS 7n
 200 An error occurred.
 201 .RE
 202 
 203 .SH ATTRIBUTES
 204 .LP
 205 See \fBattributes\fR(5) for descriptions of the following attributes:
 206 .sp
 207 
 208 .sp
 209 .TS
 210 box;
 211 c | c
 212 l | l .
 213 ATTRIBUTE TYPE  ATTRIBUTE VALUE
 214 _
 215 CSI     enabled
 216 _
 217 Interface Stability     Standard
 218 .TE
 219 
 220 .SH SEE ALSO
 221 .LP
 222 \fBtabs\fR(1), \fBattributes\fR(5), \fBenviron\fR(5), \fBstandards\fR(5)