104 lines
2.4 KiB
Groff
104 lines
2.4 KiB
Groff
.TH pad "" "" "/rdb Command"
|
|
.PC "Add extra spaces at end of last column"
|
|
\fBpad [-\fInumber\fB] < \fItableorlist\fR
|
|
.PP
|
|
.II "row^pad with spaces"
|
|
.II "table^pad"
|
|
The command
|
|
.B pad
|
|
adds extra spaces to the end of the last column of each record in
|
|
.IR tableorlist .
|
|
\fInumber\fR gives the number of spaces to add to the last column.
|
|
The default is 70.
|
|
.PP
|
|
.B pad
|
|
is useful for preparing up a file for updating by the command
|
|
.BR update .
|
|
.B update
|
|
writes an edited record back into the file in the same
|
|
place it was taken out.
|
|
If you add characters while editing the record, it will not fit.
|
|
.PP
|
|
The command
|
|
.B replace
|
|
looks for trailing and leading spaces to trim,
|
|
to fit the record back.
|
|
If it does not find enough room, it appends the record to the end of the file.
|
|
Padding gives each record a fixed number of extra spaces to be
|
|
trimmed as needed.
|
|
.PP
|
|
The traditional solution is to use fixed-length records and fields.
|
|
To do this, you can use the command
|
|
.B justify
|
|
to pad the file;
|
|
but this often increase the file by two or three times.
|
|
That makes the file much larger, and increases the time needed to process it.
|
|
.B pad
|
|
lets you control how much larger each record will be.
|
|
.SH Example
|
|
To pad file
|
|
.IR maillist ,
|
|
type:
|
|
.DM
|
|
pad < maillist > tmp
|
|
.DE
|
|
.PP
|
|
To
|
|
.B see
|
|
the results, pipe the results to the command \fBsee\fR:
|
|
.DM
|
|
pad < maillist | see
|
|
.DE
|
|
.PP
|
|
The following appears on the standard output:
|
|
.DM
|
|
Number^J1$
|
|
Name^JRonald McDonald$
|
|
Company^JMcDonald's$
|
|
Street^J123 Mac Attack$
|
|
City^JMenphis$
|
|
State^JTENN$
|
|
ZIP^J30000$
|
|
Phone^J(111) 222-3333 $
|
|
$
|
|
Number^J2$
|
|
Name^JChachita Banana$
|
|
Company^JUnited Brands$
|
|
Street^JUno Avenito De La Revolution$
|
|
City^JSan Jose$
|
|
State^JEl Salvadore$
|
|
ZIP^J123456789$
|
|
Phone^J1234 $
|
|
$
|
|
.DE
|
|
.PP
|
|
Note the dollar signs, which mark the end of the line, are
|
|
far to the right of the last column,
|
|
.IR Phone .
|
|
Those are the 70 extra spaces that have been added; 70 being the default
|
|
number of spaces.
|
|
On such a small record, that is probably far too many.
|
|
.SH Technical
|
|
Note that column
|
|
.I Phone
|
|
already had a value in it.
|
|
If a value is already in the last column,
|
|
.B pad
|
|
overwrites the spaces.
|
|
If the value is longer than the number of spaces,
|
|
.B pad
|
|
writes the value but adds no spaces.
|
|
.PP
|
|
We recommend that you have a last column named
|
|
.I Comment
|
|
or
|
|
.I Remarks
|
|
to act as a catch-all for both comments and padding.
|
|
.SH "See Also"
|
|
.B
|
|
justify,
|
|
replace,
|
|
see,
|
|
update
|
|
.R
|