160 lines
3.4 KiB
Groff
160 lines
3.4 KiB
Groff
.TH column "" "" "/rdb Command"
|
|
.PC "display columns of a table in any order"
|
|
\fBcolumn [ \fIColumn ...\fB ] < \fItableorlist\fR
|
|
.PP
|
|
.II "column^select"
|
|
.II "column^reorder"
|
|
.II "select columns"
|
|
.II "reorder columns"
|
|
The command
|
|
.B column
|
|
reads
|
|
.I tableorlist
|
|
and writes a new table (or list) that consists
|
|
of each
|
|
.IR Column ,
|
|
in the order you list them
|
|
on the command line.
|
|
.PP
|
|
If you give a column name that is not one of the columns for
|
|
.IR tableorlist ,
|
|
.B column
|
|
creates a new column with that name, in that
|
|
location, and leaves it empty.
|
|
This lets you to create new columns.
|
|
If you want to compute a column that does not exist, use this
|
|
.B column
|
|
facility to create it, then use the
|
|
.B compute
|
|
command to compute it.
|
|
However, if you misspell a column name, you will get an empty column.
|
|
.PP
|
|
If you name no
|
|
.I Column
|
|
on the command line,
|
|
.B column
|
|
writes all of
|
|
.I tableorlist
|
|
to the standard output without change.
|
|
.SH Example
|
|
Assume that you have an inventory table, as follows:
|
|
.DM
|
|
Item Amount Cost Value Description
|
|
---- ------ ----- ----- -----------
|
|
1 3 5.00 0 rubber gloves
|
|
2 100 0.50 0 test tubes
|
|
3 5 8.00 0 clamps
|
|
4 23 1.98 0 plates
|
|
5 99 2.45 0 cleaning cloth
|
|
6 89 14.75 0 bunsen burners
|
|
7 5 175 0 scales
|
|
.DE
|
|
.PP
|
|
The command:
|
|
.DM
|
|
column Cost Amount Description < inventory
|
|
.DE
|
|
.PP
|
|
produces the following output:
|
|
.DM
|
|
Cost Amount Description
|
|
----- ------ -----------
|
|
5.00 3 rubber gloves
|
|
0.50 100 test tubes
|
|
8.00 5 clamps
|
|
1.98 23 plates
|
|
2.45 99 cleaning cloth
|
|
14.75 89 bunsen burners
|
|
175 5 scales
|
|
.DE
|
|
.PP
|
|
Note that the columns
|
|
.B Cost
|
|
and
|
|
.B Amount
|
|
have been reversed.
|
|
We only have the columns we asked for and in the order we requested.
|
|
.PP
|
|
.B column
|
|
can also manipulate list-formatted files.
|
|
For example, the mailing list called
|
|
.I maillist
|
|
looks like this:
|
|
.DM
|
|
Number 1
|
|
Name Ronald McDonald
|
|
Company McDonald's
|
|
Street 123 Mac Attack
|
|
City Memphis
|
|
State TENN
|
|
ZIP 30000
|
|
Phone (111) 222-3333
|
|
.sp
|
|
Number 2
|
|
Name Chiquita Banana
|
|
Company United Brands
|
|
Street Uno Avenido de la Reforma
|
|
City San Jose
|
|
State Costa Rica
|
|
ZIP 123456789
|
|
Phone 1234
|
|
.DE
|
|
.PP
|
|
If you want only the names and numbers, type:
|
|
.DM
|
|
column Name Phone < maillist
|
|
.DE
|
|
.PP
|
|
This produces the following output:
|
|
.DM
|
|
Name Ronald McDonald
|
|
Phone (111) 222-3333
|
|
.sp
|
|
Name Chiquita Banana
|
|
Phone 1234
|
|
.DE
|
|
.SH "Case of Column Names"
|
|
.I "(Ruby re-creation only.)"
|
|
Column names are case sensitive, as in the original
|
|
.BR /rdb .
|
|
If the environment variable
|
|
.B RDB_ICASE
|
|
is set to 1, upper and lower case are ignored when column names are looked up.
|
|
An exact match always wins;
|
|
if several columns differ only in case, the command stops with an
|
|
.I ambiguous
|
|
error.
|
|
Names that are also
|
|
.B awk
|
|
reserved words or are followed by
|
|
.B (
|
|
are never taken for columns.
|
|
.SH "Deleting Columns"
|
|
.I "(Ruby re-creation only.)"
|
|
.DM
|
|
column -d Column ... < tableorlist
|
|
.DE
|
|
.PP
|
|
With the option
|
|
.BR -d ,
|
|
.B column
|
|
keeps every column
|
|
.I except
|
|
those named.
|
|
The order of the other columns stays as it is.
|
|
It is an error to name a column that does not exist,
|
|
or to delete every column.
|
|
.DM
|
|
subtotal Date Debit Credit < journal | column -d Account Description
|
|
.DE
|
|
.SH "See Also"
|
|
.B
|
|
project,
|
|
row
|
|
.R
|
|
.br
|
|
COHERENT Lexicon:
|
|
.B
|
|
awk
|
|
.R
|