Rdb: Ruby-Nachbau der MWC /rdb-Werkzeuge
This commit is contained in:
+139
@@ -0,0 +1,139 @@
|
||||
.TH justify "" "" "/rdb Command"
|
||||
.PC "Left or right justify the columns of a table"
|
||||
\fBjustify [-elrct'\fIc\fB'] [ \fIcolumn ... \fB] < \fItable\fR
|
||||
.PP
|
||||
.II "table^justify"
|
||||
.II "column^justify"
|
||||
.II "justify columns"
|
||||
The command
|
||||
.B justify
|
||||
right-justifies the columns that contain only numbers, and
|
||||
left-justifies the columns that contain any nonnumeric characters.
|
||||
It also lines up floating-point numbers on their decimal points.
|
||||
.PP
|
||||
.B justify
|
||||
improves the appearance of a table.
|
||||
This makes it easier for you to read and edit.
|
||||
It also makes a column of variable-length strings into one
|
||||
length, by padding each string with spaces on the right.
|
||||
Note that the extra spaces inserted to improve a table's appearance
|
||||
could easily double or triple the size of the table.
|
||||
This increased size not only takes up disk space, but slows processing of
|
||||
.IR table .
|
||||
You must decide whether appearance or size is more important.
|
||||
.SH Options
|
||||
.B justify
|
||||
recognizes the following options:
|
||||
.IP \fB\-e\fR
|
||||
Expand the column to the next tab stop.
|
||||
Ordinarily, a column is only as wide as the widest data or column name.
|
||||
This improves the appear, but increases the size of the file.
|
||||
.PP
|
||||
The following options
|
||||
override the default justifications (left-justify character strings,
|
||||
right-justify numbers):
|
||||
.IP \fB\-l\fR
|
||||
(This is the letter ``el'', not the number one.)
|
||||
Left-justify all named columns.
|
||||
.IP \fB\-c\fR
|
||||
Center all named columns.
|
||||
.IP \fB\-r\fR
|
||||
Right justify all named columns.
|
||||
.PP
|
||||
These options are sticky, meaning that if you follow an
|
||||
.BR l ,
|
||||
.BR c ,
|
||||
or
|
||||
.R r
|
||||
option with several column names, each is treated according to
|
||||
the option.
|
||||
For example,
|
||||
.B "\-l Description Account"
|
||||
left justifies both
|
||||
.B Account
|
||||
and
|
||||
.BR Description ,
|
||||
regardless of the data each contains.
|
||||
.PP
|
||||
.IP "\fB\-t\(aa\fIc\fB\(aa\fR"
|
||||
Use the character
|
||||
.I c
|
||||
as the column separator instead of tab.
|
||||
.I c
|
||||
can be any ASCII character.
|
||||
Note, however, that once you process a table with this option,
|
||||
you can no longer use
|
||||
.B /rdb
|
||||
commands on it, because all
|
||||
.B /rdb
|
||||
commands require tabs as column separators.
|
||||
See the command
|
||||
.B trim
|
||||
for a discussion of how you can protect special characters from the shell.
|
||||
.SH Example
|
||||
One use of
|
||||
.B justify
|
||||
is to align columns.
|
||||
Variable-length character columns (like names and
|
||||
descriptions) destroy the alignment of columns.
|
||||
For example, notice how the variable-length names cause the tabs to
|
||||
break at different points in the following table:
|
||||
.DM
|
||||
Name Credit
|
||||
---- -------
|
||||
Anderson 23.49
|
||||
Ho 145.98
|
||||
Johnson 1.15
|
||||
.DE
|
||||
.PP
|
||||
One solution is to move the variable length column to the last column:
|
||||
.DM
|
||||
column Credit Name < credit
|
||||
.DE
|
||||
.PP
|
||||
The table now appears as follows:
|
||||
.DM
|
||||
Credit Name
|
||||
------- ---------------
|
||||
23.49 Anderson
|
||||
145.98 Ho
|
||||
1.15 Johnson
|
||||
.DE
|
||||
.PP
|
||||
Another solution is to use
|
||||
.B justify
|
||||
to right-pad the
|
||||
.B Name
|
||||
column, and (while we're at it) align the floating point number in the
|
||||
.BR Credit :
|
||||
.DM
|
||||
.ta 1.5i
|
||||
Name Credit
|
||||
-------- ------
|
||||
Anderson 23.49
|
||||
Ho 145.98
|
||||
Johnson 1.15
|
||||
.DE
|
||||
.PP
|
||||
Remember that the file is now larger.
|
||||
All of those extra blank spaces can double or triple the size of your file.
|
||||
.PP
|
||||
It is easier to enter the initial data into a table without
|
||||
the padding characters.
|
||||
Then you can use
|
||||
.B justify
|
||||
to pretty up the table.
|
||||
.PP
|
||||
When using the command
|
||||
.B listtotable
|
||||
to convert a list-format file to a table,
|
||||
you may wish to use
|
||||
.B justify
|
||||
to make the resulting table readable.
|
||||
.SH "See Also"
|
||||
.B
|
||||
column,
|
||||
compresss,
|
||||
listtotable,
|
||||
trim
|
||||
.R
|
||||
Reference in New Issue
Block a user