BSD 4_4 development
[unix-history] / usr / share / man / cat1 / rs.0
CommitLineData
22072751
C
1
2
3
4RS(1) BSD Reference Manual RS(1)
5
6
7N\bNA\bAM\bME\bE
8 rs - reshape a data array
9
10S\bSY\bYN\bNO\bOP\bPS\bSI\bIS\bS
11 r\brs\bs [\b[ -\b-[\b[c\bcs\bsC\bCS\bS]\b][\b[x]\b][\b[k\bkK\bKg\bgG\bGw\bw]\b][\b[N]\b]t\btT\bTe\beE\bEn\bny\byj\bjh\bhH\bHm\bm ]\b] [\b[ rows [\b[ cols ]\b] ]\b]
12
13D\bDE\bES\bSC\bCR\bRI\bIP\bPT\bTI\bIO\bON\bN
14 _\bR_\bs reads the standard input, interpreting each line as a
15 row of blank-separated entries in an array, transforms the
16 array according to the options, and writes it on the stan-
17 dard output. With no arguments it transforms stream input
18 into a columnar format convenient for terminal viewing.
19
20 The shape of the input array is deduced from the number of
21 lines and the number of columns on the first line. If
22 that shape were inconvenient, a more useful one might be
23 obtained by skipping some of the input with the -\b-k\bk option.
24 Other options control interpretation of the input columns.
25
26 The shape of the output array is influenced by the _\br_\bo_\bw_\bs
27 and _\bc_\bo_\bl_\bs specifications, which should be positive inte-
28 gers. If only one of them is a positive integer, _\br_\bs com-
29 putes a value for the other which will accommodate all of
30 the data. When necessary, missing data are supplied in a
31 manner specified by the options and surplus data are
32 deleted. There are options to control presentation of the
33 output columns, including transposition of the rows and
34 columns.
35
36 The options are described below.
37
38 -\b-c\bcx Input columns are delimited by the single character
39 _\bx. A missing _\bx is taken to be `^I'.
40
41 -\b-s\bsx Like -\b-c\bc, but maximal strings of _\bx are delimiters.
42
43 -\b-C\bCx Output columns are delimited by the single charac-
44 ter _\bx. A missing _\bx is taken to be `^I'.
45
46 -\b-S\bSx Like -\b-C\bC, but padded strings of _\bx are delimiters.
47
48 -\b-t\bt Fill in the rows of the output array using the
49 columns of the input array, that is, transpose the
50 input while honoring any _\br_\bo_\bw_\bs and _\bc_\bo_\bl_\bs specifica-
51 tions.
52
53 -\b-T\bT Print the pure transpose of the input, ignoring any
54 _\br_\bo_\bw_\bs or _\bc_\bo_\bl_\bs specification.
55
56 -\b-k\bkN Ignore the first _\bN lines of input.
57
58
59
60
614th Berkeley Distribution June 6, 1993 1
62
63
64
65
66
67
68
69
70RS(1) BSD Reference Manual RS(1)
71
72
73 -\b-K\bKN Like -\b-k\bk, but print the ignored lines.
74
75 -\b-g\bgN The gutter width (inter-column space), normally 2,
76 is taken to be _\bN.
77
78 -\b-G\bGN The gutter width has _\bN percent of the maximum col-
79 umn width added to it.
80
81 -\b-e\be Consider each line of input as an array entry.
82
83 -\b-n\bn On lines having fewer entries than the first line,
84 use null entries to pad out the line. Normally,
85 missing entries are taken from the next line of
86 input.
87
88 -\b-y\by If there are too few entries to make up the output
89 dimensions, pad the output by recycling the input
90 from the beginning. Normally, the output is padded
91 with blanks.
92
93 -\b-h\bh Print the shape of the input array and do nothing
94 else. The shape is just the number of lines and
95 the number of entries on the first line.
96
97 -\b-H\bH Like -\b-h\bh, but also print the length of each line.
98
99 -\b-j\bj Right adjust entries within columns.
100
101 -\b-w\bwN The width of the display, normally 80, is taken to
102 be the positive integer _\bN.
103
104 -\b-m\bm Do not trim excess delimiters from the ends of the
105 output array.
106
107 With no arguments, _\br_\bs transposes its input, and assumes
108 one array entry per input line unless the first non-
109 ignored line is longer than the display width. Option
110 letters which take numerical arguments interpret a missing
111 number as zero unless otherwise indicated.
112
113E\bEX\bXA\bAM\bMP\bPL\bLE\bES\bS
114 _\bR_\bs can be used as a filter to convert the stream output of
115 certain programs (e.g., _\bs_\bp_\be_\bl_\bl, _\bd_\bu, _\bf_\bi_\bl_\be, _\bl_\bo_\bo_\bk, _\bn_\bm, _\bw_\bh_\bo,
116 and _\bw_\bc(1)) into a convenient ``window'' format, as in
117
118 w\bwh\bho\bo |\b| r\brs\bs
119
120 This function has been incorporated into the _\bl_\bs(1) pro-
121 gram, though for most programs with similar output _\br_\bs suf-
122 fices.
123
124
125
126
1274th Berkeley Distribution June 6, 1993 2
128
129
130
131
132
133
134
135
136RS(1) BSD Reference Manual RS(1)
137
138
139 To convert stream input into vector output and back again,
140 use
141
142 r\brs\bs 1\b1 0\b0 |\b| r\brs\bs 0\b0 1\b1
143
144 A 10 by 10 array of random numbers from 1 to 100 and its
145 transpose can be generated with
146
147 j\bjo\bot\bt -\b-r\br 1\b10\b00\b0 |\b| r\brs\bs 1\b10\b0 1\b10\b0 |\b| t\bte\bee\be a\bar\brr\bra\bay\by
148 |\b| r\brs\bs -\b-T\bT >\b> t\bta\bar\brr\bra\bay\by
149
150 In the editor _\bv_\bi(1), a file consisting of a multi-line
151 vector with 9 elements per line can undergo insertions and
152 deletions, and then be neatly reshaped into 9 columns with
153
154 :\b:1\b1,\b,$\b$!\b!r\brs\bs 0\b0 9\b9
155
156 Finally, to sort a database by the first line of each
157 4-line field, try
158
159 r\brs\bs -\b-e\beC\bC 0\b0 4\b4 |\b| s\bso\bor\brt\bt |\b| r\brs\bs -\b-c\bc 0\b0 1\b1
160
161
162S\bSE\bEE\bE A\bAL\bLS\bSO\bO
163 jot(1), vi(1), sort(1), pr(1)
164
165B\bBU\bUG\bGS\bS
166 Handles only two dimensional arrays.
167
168 The algorithm currently reads the whole file into memory,
169 so files that do not fit in memory will not be reshaped.
170
171 Fields cannot be defined yet on character positions.
172
173 Re-ordering of columns is not yet possible.
174
175 There are too many options.
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
1934th Berkeley Distribution June 6, 1993 3
194
195
196
197
198