Files
rdb/man/column.man
T

126 lines
2.5 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 "See Also"
.B
project,
row
.R
.br
COHERENT Lexicon:
.B
awk
.R