Annotation of 43BSD/contrib/tools/man/rs.1, revision 1.1.1.1

1.1       root        1: .TH RS 1 "14 June 1983"
                      2: .UC 4
                      3: .SH NAME
                      4: rs \- reshape a data array
                      5: .SH SYNOPSIS
                      6: \fBrs [ \-[csCS][\fRx\fB][kKgGw][\fRN\fB]tTeEnyjhHm ] [ \fRrows\fB [ \fRcols\fB ] ]\fR
                      7: .SH DESCRIPTION
                      8: .I Rs
                      9: reads the standard input, interpreting each line as a row
                     10: of blank-separated entries in an array,
                     11: transforms the array according to the options,
                     12: and writes it on the standard output.
                     13: With no arguments it transforms stream input into a columnar
                     14: format convenient for terminal viewing.
                     15: .PP
                     16: The shape of the input array is deduced from the number of lines
                     17: and the number of columns on the first line.
                     18: If that shape were inconvenient, a more useful one might be
                     19: obtained by skipping some of the input with the \fB\-k\fP option.
                     20: Other options control interpretation of the input columns.
                     21: .PP
                     22: The shape of the output array is influenced by the
                     23: .I rows
                     24: and
                     25: .I cols
                     26: specifications, which should be positive integers.
                     27: If only one of them is a positive integer,
                     28: .I rs
                     29: computes a value for the other which will accommodate
                     30: all of the data.
                     31: When necessary, missing data are supplied in a manner
                     32: specified by the options and surplus data are deleted.
                     33: There are options to control presentation of the output columns,
                     34: including transposition of the rows and columns.
                     35: .PP
                     36: The options are described below.
                     37: .IP \fB\-c\fRx
                     38: Input columns are delimited by the single character \fIx\fP.
                     39: A missing \fIx\fP is taken to be `^I'.
                     40: .IP \fB\-s\fRx
                     41: Like \fB\-c\fR, but maximal strings of \fIx\fP are delimiters.
                     42: .IP \fB\-C\fRx
                     43: Output columns are delimited by the single character \fIx\fP.
                     44: A missing \fIx\fP is taken to be `^I'.
                     45: .IP \fB\-S\fRx
                     46: Like \fB\-C\fR, but padded strings of \fIx\fP are delimiters.
                     47: .IP \fB\-t\fR
                     48: Fill in the rows of the output array using the columns of the
                     49: input array, that is, transpose the input while honoring any
                     50: .I rows
                     51: and
                     52: .I cols
                     53: specifications.
                     54: .IP \fB\-T\fR
                     55: Print the pure transpose of the input, ignoring any
                     56: .I rows
                     57: or
                     58: .I cols
                     59: specification.
                     60: .IP \fB\-k\fRN
                     61: Ignore the first \fIN\fR lines of input.
                     62: .IP \fB\-K\fRN
                     63: Like \fB\-k\fR, but print the ignored lines.
                     64: .IP \fB\-g\fRN
                     65: The gutter width (inter-column space), normally 2, is taken to be \fIN\fR.
                     66: .IP \fB\-G\fRN
                     67: The gutter width has \fIN\fR percent of the maximum
                     68: column width added to it.
                     69: .IP \fB\-e\fR
                     70: Consider each line of input as an array entry.
                     71: .IP \fB\-n\fR
                     72: On lines having fewer entries than the first line,
                     73: use null entries to pad out the line.
                     74: Normally, missing entries are taken from the next line of input.
                     75: .IP \fB\-y\fR
                     76: If there are too few entries to make up the output dimensions,
                     77: pad the output by recycling the input from the beginning.
                     78: Normally, the output is padded with blanks.
                     79: .IP \fB\-h\fR
                     80: Print the shape of the input array and do nothing else.
                     81: The shape is just the number of lines and the number of
                     82: entries on the first line.
                     83: .IP \fB\-H\fR
                     84: Like \fB\-h\fR, but also print the length of each line.
                     85: .IP \fB\-j\fR
                     86: Right adjust entries within columns.
                     87: .IP \fB\-w\fRN
                     88: The width of the display, normally 80, is taken to be the positive
                     89: integer \fIN\fP.
                     90: .IP \fB\-m\fR
                     91: Do not trim excess delimiters from the ends of the output array.
                     92: .PP
                     93: With no arguments,
                     94: .I rs
                     95: transposes its input, and assumes one array entry per input line
                     96: unless the first non-ignored line is longer than the display width.
                     97: Option letters which take numerical arguments interpret a missing
                     98: number as zero unless otherwise indicated.
                     99: .SH EXAMPLES
                    100: .de IC
                    101: .IP
                    102: .ss 36
                    103: .ft B
                    104: ..
                    105: .de NC
                    106: .br
                    107: .ss 12
                    108: .PP
                    109: ..
                    110: .I Rs
                    111: can be used as a filter to convert the stream output
                    112: of certain programs (e.g.,
                    113: .IR spell ,
                    114: .IR du ,
                    115: .IR file ,
                    116: .IR look ,
                    117: .IR nm ,
                    118: .IR who ,
                    119: and
                    120: .IR wc (1))
                    121: into a convenient ``window'' format, as in
                    122: .IC
                    123: who | rs
                    124: .NC
                    125: This function has been incorporated into the
                    126: .IR ls (1)
                    127: program, though for most programs with similar output
                    128: .I rs
                    129: suffices.
                    130: .PP
                    131: To convert stream input into vector output and back again, use
                    132: .IC
                    133: rs 1 0 | rs 0 1
                    134: .NC
                    135: A 10 by 10 array of random numbers from 1 to 100 and
                    136: its transpose can be generated with
                    137: .IC
                    138: jot \-r 100 | rs 10 10 | tee array | rs \-T > tarray
                    139: .NC
                    140: In the editor
                    141: .IR vi (1),
                    142: a file consisting of a multi-line vector with 9 elements per line
                    143: can undergo insertions and deletions,
                    144: and then be neatly reshaped into 9 columns with
                    145: .IC
                    146: :1,$!rs 0 9
                    147: .NC
                    148: Finally, to sort a database by the first line of each 4-line field, try
                    149: .IC
                    150: rs \-eC 0 4 | sort | rs \-c 0 1
                    151: .NC
                    152: .SH SEE ALSO
                    153: jot(1), vi(1), sort(1), pr(1)
                    154: .SH AUTHOR
                    155: John Kunze
                    156: .SH BUGS
                    157: Handles only two dimensional arrays.
                    158: 
                    159: The algorithm currently reads the whole file into memory,
                    160: so files that do not fit in memory will not be reshaped.
                    161: 
                    162: Fields cannot be defined yet on character positions.
                    163: 
                    164: Re-ordering of columns is not yet possible.
                    165: 
                    166: There are too many options.

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.