[BACK]Return to rs.1 CVS log [TXT][DIR] Up to [local] / src / usr.bin / rs

Diff for /src/usr.bin/rs/rs.1 between version 1.4 and 1.5

version 1.4, 1999/10/17 20:24:35 version 1.5, 2000/03/06 12:23:41
Line 32 
Line 32 
 .\" SUCH DAMAGE.  .\" SUCH DAMAGE.
 .\"  .\"
 .\"     @(#)rs.1        8.2 (Berkeley) 12/30/93  .\"     @(#)rs.1        8.2 (Berkeley) 12/30/93
   .\" $FreeBSD: src/usr.bin/rs/rs.1,v 1.4 1999/08/28 01:05:21 peter Exp $
 .\"  .\"
 .TH RS 1 "December 30, 1993"  .Dd December 30, 1993
 .UC 4  .Dt RS 1
 .SH NAME  .Os
 rs \- reshape a data array  .Sh NAME
 .SH SYNOPSIS  .Nm rs
 \fBrs [ \-[csCS][\fRx\fB][kKgGw][\fRN\fB]tTeEnyjhHm ] [ \fRrows\fB [ \fRcols\fB ] ]\fR  .Nd reshape a data array
 .SH DESCRIPTION  .Sh SYNOPSIS
 .I Rs  .Nm rs
   .Oo
   .Sm off
   .Xo Fl Oo Cm Op Cm csCS
   .Op Ar x
   .Op Cm kKgGw
   .Op Ar N
   .Cm tTeEnyjhHmz Oc
   .Xc
   .Oc
   .Sm on
   .Op Ar rows Op Ar cols
   .Sh DESCRIPTION
   .Nm
 reads the standard input, interpreting each line as a row  reads the standard input, interpreting each line as a row
 of blank-separated entries in an array,  of blank-separated entries in an array,
 transforms the array according to the options,  transforms the array according to the options,
 and writes it on the standard output.  and writes it on the standard output.
 With no arguments it transforms stream input into a columnar  With no arguments it transforms stream input into a columnar
 format convenient for terminal viewing.  format convenient for terminal viewing.
 .PP  .Pp
 The shape of the input array is deduced from the number of lines  The shape of the input array is deduced from the number of lines
 and the number of columns on the first line.  and the number of columns on the first line.
 If that shape is inconvenient, a more useful one might be  If that shape is inconvenient, a more useful one might be
 obtained by skipping some of the input with the \fB\-k\fP option.  obtained by skipping some of the input with the
   .Fl k
   option.
 Other options control interpretation of the input columns.  Other options control interpretation of the input columns.
 .PP  .Pp
 The shape of the output array is influenced by the  The shape of the output array is influenced by the
 .I rows  .Ar rows
 and  and
 .I cols  .Ar cols
 specifications, which should be positive integers.  specifications, which should be positive integers.
 If only one of them is a positive integer,  If only one of them is a positive integer,
 .I rs  .Nm
 computes a value for the other which will accommodate  computes a value for the other which will accommodate
 all of the data.  all of the data.
 When necessary, missing data are supplied in a manner  When necessary, missing data are supplied in a manner
 specified by the options and surplus data are deleted.  specified by the options and surplus data are deleted.
 There are options to control presentation of the output columns,  There are options to control presentation of the output columns,
 including transposition of the rows and columns.  including transposition of the rows and columns.
 .PP  .Pp
 The options are as follows:  The options are as follows:
 .IP \fB\-c\fRx  .Bl -tag -width indent
 Input columns are delimited by the single character \fIx\fP.  .It Fl c Ns Ar x
 A missing \fIx\fP is taken to be `^I'.  Input columns are delimited by the single character
 .IP \fB\-s\fRx  .Ar x .
 Like \fB\-c\fR, but maximal strings of \fIx\fP are delimiters.  A missing
 .IP \fB\-C\fRx  .Ar x
 Output columns are delimited by the single character \fIx\fP.  is taken to be
 A missing \fIx\fP is taken to be `^I'.  .Ql ^I .
 .IP \fB\-S\fRx  .It Fl s Ns Ar x
 Like \fB\-C\fR, but padded strings of \fIx\fP are delimiters.  Like
 .IP \fB\-t\fR  .Fl c ,
   but maximal strings of
   .Ar x
   are delimiters.
   .It Fl C Ns Ar x
   Output columns are delimited by the single character
   .Ar x .
   A missing
   .Ar x
   is taken to be
   .Ql ^I .
   .It Fl S Ns Ar x
   Like
   .Fl C ,
   but padded strings of
   .Ar x
   are delimiters.
   .It Fl t
 Fill in the rows of the output array using the columns of the  Fill in the rows of the output array using the columns of the
 input array, that is, transpose the input while honoring any  input array, that is, transpose the input while honoring any
 .I rows  .Ar rows
 and  and
 .I cols  .Ar cols
 specifications.  specifications.
 .IP \fB\-T\fR  .It Fl T
 Print the pure transpose of the input, ignoring any  Print the pure transpose of the input, ignoring any
 .I rows  .Ar rows
 or  or
 .I cols  .Ar cols
 specification.  specification.
 .IP \fB\-k\fRN  .It Fl k Ns Ar N
 Ignore the first \fIN\fR lines of input.  Ignore the first
 .IP \fB\-K\fRN  .Ar N
 Like \fB\-k\fR, but print the ignored lines.  lines of input.
 .IP \fB\-g\fRN  .It Fl K Ns Ar N
 The gutter width (inter-column space), normally 2, is taken to be \fIN\fR.  Like
 .IP \fB\-G\fRN  .Fl k ,
 The gutter width has \fIN\fR percent of the maximum  but print the ignored lines.
 column width added to it.  .It Fl g Ns Ar N
 .IP \fB\-e\fR  The gutter width (inter-column space), normally 2, is taken to be
   .Ar N .
   .It Fl G Ns Ar N
   The gutter width has
   .Ar N
   percent of the maximum column width added to it.
   .It Fl e
 Consider each line of input as an array entry.  Consider each line of input as an array entry.
 .IP \fB\-n\fR  .It Fl E
   Consider each character of input as an array entry.
   .It Fl n
 On lines having fewer entries than the first line,  On lines having fewer entries than the first line,
 use null entries to pad out the line.  use null entries to pad out the line.
 Normally, missing entries are taken from the next line of input.  Normally, missing entries are taken from the next line of input.
 .IP \fB\-y\fR  .It Fl y
 If there are too few entries to make up the output dimensions,  If there are too few entries to make up the output dimensions,
 pad the output by recycling the input from the beginning.  pad the output by recycling the input from the beginning.
 Normally, the output is padded with blanks.  Normally, the output is padded with blanks.
 .IP \fB\-h\fR  .It Fl h
 Print the shape of the input array and do nothing else.  Print the shape of the input array and do nothing else.
 The shape is just the number of lines and the number of  The shape is just the number of lines and the number of
 entries on the first line.  entries on the first line.
 .IP \fB\-H\fR  .It Fl H
 Like \fB\-h\fR, but also print the length of each line.  Like
 .IP \fB\-j\fR  .Fl h ,
   but also print the length of each line.
   .It Fl j
 Right adjust entries within columns.  Right adjust entries within columns.
 .IP \fB\-w\fRN  .It Fl w Ns Ar N
 The width of the display, normally 80, is taken to be the positive  The width of the display, normally 80, is taken to be the positive
 integer \fIN\fP.  integer
 .IP \fB\-m\fR  .Ar N .
   .It Fl m
 Do not trim excess delimiters from the ends of the output array.  Do not trim excess delimiters from the ends of the output array.
 .IP \fB\-z\fR  .It Fl z
 Adapt column widths to fit the largest entries appearing in them.  Adapt column widths to fit the largest entries appearing in them.
 .PP  .El
   .Pp
 With no arguments,  With no arguments,
 .I rs  .Nm
 transposes its input, and assumes one array entry per input line  transposes its input, and assumes one array entry per input line
 unless the first non-ignored line is longer than the display width.  unless the first non-ignored line is longer than the display width.
 Option letters which take numerical arguments interpret a missing  Option letters which take numerical arguments interpret a missing
 number as zero unless otherwise indicated.  number as zero unless otherwise indicated.
 .SH EXAMPLES  .Sh EXAMPLES
 .de IC  .Nm
 .IP  
 .ss 36  
 .ft B  
 ..  
 .de NC  
 .br  
 .ss 12  
 .PP  
 ..  
 .I Rs  
 can be used as a filter to convert the stream output  can be used as a filter to convert the stream output
 of certain programs (e.g.,  of certain programs (e.g.,
 .IR spell ,  .Xr spell ,
 .IR du ,  .Xr du ,
 .IR file ,  .Xr file ,
 .IR look ,  .Xr look ,
 .IR nm ,  .Xr nm ,
 .IR who ,  .Xr who ,
 and  and
 .IR wc (1))  .Xr wc 1 )
 into a convenient ``window'' format, as in  into a convenient
 .IC  .Dq window
 who | rs  format, as in
 .NC  .Bd -literal -offset indent
   % who | rs
   .Ed
   .Pp
 This function has been incorporated into the  This function has been incorporated into the
 .IR ls (1)  .Xr ls 1
 program, though for most programs with similar output  program, though for most programs with similar output
 .I rs  .Nm
 suffices.  suffices.
 .PP  .Pp
 To convert stream input into vector output and back again, use  To convert stream input into vector output and back again, use
 .IC  .Bd -literal -offset indent
 rs 1 0 | rs 0 1  % rs 1 0 | rs 0 1
 .NC  .Ed
   .Pp
 A 10 by 10 array of random numbers from 1 to 100 and  A 10 by 10 array of random numbers from 1 to 100 and
 its transpose can be generated with  its transpose can be generated with
 .IC  .Bd -literal -offset indent
 jot \-r 100 | rs 10 10 | tee array | rs \-T > tarray  % jot \-r 100 | rs 10 10 | tee array | rs \-T > tarray
 .NC  .Ed
   .Pp
 In the editor  In the editor
 .IR vi (1),  .Xr vi 1 ,
 a file consisting of a multi-line vector with 9 elements per line  a file consisting of a multi-line vector with 9 elements per line
 can undergo insertions and deletions,  can undergo insertions and deletions,
 and then be neatly reshaped into 9 columns with  and then be neatly reshaped into 9 columns with
 .IC  .Bd -literal -offset indent
 :1,$!rs 0 9  :1,$!rs 0 9
 .NC  .Ed
   .Pp
 Finally, to sort a database by the first line of each 4-line field, try  Finally, to sort a database by the first line of each 4-line field, try
 .IC  .Bd -literal -offset indent
 rs \-eC 0 4 | sort | rs \-c 0 1  % rs \-eC 0 4 | sort | rs \-c 0 1
 .NC  .Ed
 .SH SEE ALSO  .Sh SEE ALSO
 jot(1), vi(1), sort(1), pr(1)  .Xr jot 1 ,
 .SH BUGS  .Xr pr 1 ,
   .Xr sort 1 ,
   .Xr vi 1
   .Sh BUGS
 Handles only two dimensional arrays.  Handles only two dimensional arrays.
   .Pp
 The algorithm currently reads the whole file into memory,  The algorithm currently reads the whole file into memory,
 so files that do not fit in memory will not be reshaped.  so files that do not fit in memory will not be reshaped.
   .Pp
 Fields cannot be defined yet on character positions.  Fields cannot be defined yet on character positions.
   .Pp
 Re-ordering of columns is not yet possible.  Re-ordering of columns is not yet possible.
   .Pp
 There are too many options.  There are too many options.

Legend:
Removed from v.1.4  
changed lines
  Added in v.1.5