Rdb: Ruby-Nachbau der MWC /rdb-Werkzeuge
This commit is contained in:
@@ -0,0 +1,74 @@
|
||||
.TH "accounting terms" "" "" Definition
|
||||
.PC
|
||||
.PP
|
||||
The following defines several of the more commonly used accounting
|
||||
terms.
|
||||
These are included to help you understand the descriptions of \fB/rdb\fR's
|
||||
accounting package.
|
||||
.PP
|
||||
Financial information that records the day-to-day operation of a
|
||||
business is recorded in an
|
||||
.IR account .
|
||||
A simple account is made up of three parts:
|
||||
.IP \fB1.\fR 0.3i
|
||||
A title that describes the name of the information being stored
|
||||
in the account;
|
||||
.IP \fB2.\fR
|
||||
The left side of the account, used to record a debit; and
|
||||
.IP \fB3.\fR
|
||||
The right side of the account, used to record a credit.
|
||||
.PP
|
||||
This simple configuration is referred to as a `T' account because its
|
||||
shape resembles a capital T:
|
||||
.DM
|
||||
Title
|
||||
===================================
|
||||
Debit | Credit
|
||||
.DE
|
||||
.PP
|
||||
A
|
||||
.I ledger
|
||||
is the combination of all the accounts maintained by a business.
|
||||
Transactions are posted to accounts through a
|
||||
.IR "journal entry" ,
|
||||
as in the following example:
|
||||
.DM
|
||||
Cash | 500.00 |
|
||||
Sales | | 500.00
|
||||
.DE
|
||||
.PP
|
||||
Entries recorded on the far left are debits;
|
||||
entries indented from the left are credits.
|
||||
.PP
|
||||
Accounts fall into the following classifications:
|
||||
.IP \fBAssets\fR
|
||||
Anything that is owned and has a monetary value.
|
||||
.IP \fBLiabilities\fR
|
||||
Amounts owed to others.
|
||||
.IP \fBCapital\fR
|
||||
This is the owner's equity in the business.
|
||||
It is equal to the total assets minus the total liabilities.
|
||||
.IP \fBRevenue\fR
|
||||
Proceeds obtained in the course of doing business.
|
||||
.IP \fBExpenses\fR
|
||||
Costs incurred in the course of doing business.
|
||||
.PP
|
||||
Further information on accounting terms may be obtained from any
|
||||
textbook on accounting principles.
|
||||
Your local public library should contain several examples.
|
||||
.SH "See Also"
|
||||
.B
|
||||
act
|
||||
.R
|
||||
.SH Notes
|
||||
Please note that
|
||||
.BR /rdb 's
|
||||
accounting system is meant to serve as an example of data-base programming
|
||||
with
|
||||
.BR /rdb .
|
||||
It is not designed to be an exhaustive accounting package, nor is it
|
||||
designed to teach you how to perform accounting.
|
||||
Mark Williams technical support will help you if you have a problem with an
|
||||
.BR /rdb
|
||||
command, but not with problems that involve the principles of accounting.
|
||||
.IR "Caveat utilitor" .
|
||||
+72
@@ -0,0 +1,72 @@
|
||||
.TH act "" "" "/rdb Command"
|
||||
.PC "List all /act commands"
|
||||
.B act
|
||||
.PP
|
||||
.II "accounting system"
|
||||
.B /rdb
|
||||
comes with a set of commands that implement a basic accounting system,
|
||||
suitable for running a small business.
|
||||
These commands, called
|
||||
.B /act
|
||||
commands,
|
||||
are kept in directory
|
||||
.BR $RDB/act .
|
||||
.PP
|
||||
The accounting system consists of the following sub-systems:
|
||||
.II "general ledger"
|
||||
.IP \fBgl\fR 0.3i
|
||||
General ledger
|
||||
.II inventory
|
||||
.IP \fBinv\fR
|
||||
Inventory
|
||||
.II operations
|
||||
.IP \fBopr\fR
|
||||
Operations, for manufacturing
|
||||
.II payroll
|
||||
.IP \fBpay\fR
|
||||
Payroll
|
||||
.II "accounts payable"
|
||||
.II purchasing
|
||||
.IP \fBpur\fR
|
||||
Accounts payable and purchasing
|
||||
.II sales
|
||||
.IP \fBsales\fR
|
||||
Accounts payable and sales
|
||||
.PP
|
||||
The command
|
||||
.B act
|
||||
lists all
|
||||
.B /act
|
||||
commands.
|
||||
.SH Example
|
||||
Typing
|
||||
.B act
|
||||
displaying the following on your screen:
|
||||
.DM
|
||||
act close income postap shorttoaccount
|
||||
adjust consolidate invoice postar start
|
||||
balance cstate makecatalog postpay tax.calc
|
||||
bom fillform onhand purchase trial
|
||||
calculate foot po sale vstate
|
||||
chartdup getjournal post ship w2
|
||||
.DE
|
||||
.PP
|
||||
Many
|
||||
.B act
|
||||
commands have their own entries in this manual.
|
||||
.SH "See Also"
|
||||
.B
|
||||
accounting terms
|
||||
.R
|
||||
.SH Notes
|
||||
Please note that
|
||||
.BR /rdb 's
|
||||
accounting system is meant to serve as an example of data-base programming
|
||||
with
|
||||
.BR /rdb .
|
||||
It is not designed to be an exhaustive accounting package, nor is it
|
||||
designed to teach you how to perform accounting.
|
||||
Mark Williams technical support will help you if you have a problem with an
|
||||
.BR /rdb
|
||||
command, but not with problems that involve the principles of accounting.
|
||||
.IR "Caveat utilitor" .
|
||||
@@ -0,0 +1,41 @@
|
||||
.TH addcol "" "" "/rdb Command"
|
||||
.PC "Add a column to a table"
|
||||
\fBaddcol \fInewcolumn \fB< \fItable\fR
|
||||
.PP
|
||||
.II "add column to table"
|
||||
.II "column^add to table"
|
||||
The command
|
||||
.B addcol
|
||||
appends one or more new columns to
|
||||
.IR table .
|
||||
The column is initialized to blank spaces, and is given the name
|
||||
.IR newcolumn .
|
||||
.SH Example
|
||||
The command
|
||||
.DM
|
||||
addcol New < inventory
|
||||
.DE
|
||||
.PP
|
||||
modifies table
|
||||
.B inventory
|
||||
to appear as follows:
|
||||
.DM
|
||||
Item Amount Cost Value Description New
|
||||
---- ------ ---- ----- -------------- -------
|
||||
1 3 50 150 rubber gloves
|
||||
2 100 5 500 test tubes
|
||||
3 5 80 400 clamps
|
||||
4 23 19 437 plates
|
||||
5 99 24 2376 cleaning cloth
|
||||
6 89 147 13083 bunsen burners
|
||||
7 5 175 875 scales
|
||||
.DE
|
||||
.PP
|
||||
Note that column
|
||||
.B New
|
||||
has been added to the table.
|
||||
.SH "See Also"
|
||||
.B
|
||||
jointable,
|
||||
number
|
||||
.R
|
||||
@@ -0,0 +1,95 @@
|
||||
.TH adjust "" "" "/act/gl Command"
|
||||
.PC "Create adjusted trial balance table"
|
||||
.B adjust
|
||||
.PP
|
||||
.II "adjust balance sheet"
|
||||
The command
|
||||
.B adjust
|
||||
is part of the accounting/general ledger system
|
||||
that is included with
|
||||
.BR /rdb .
|
||||
It produces the adjusted trial balance sheet, called
|
||||
.BR adjusttrial ,
|
||||
by adding the trial-balance table
|
||||
.B trialbalance
|
||||
with the journal-of-adjustments table
|
||||
.BR journaladjust .
|
||||
.PP
|
||||
The accountant makes
|
||||
adjustments at the end of the accounting period,
|
||||
to reflect changes in inventory, depreciation, depletion, amortization,
|
||||
and so on.
|
||||
These are computed costs of doing business that are
|
||||
assigned to each accounting period.
|
||||
.SH Example
|
||||
The following gives an example of table
|
||||
.BR trialbalance :
|
||||
.DM
|
||||
Account Debit Credit Format Taxline Short Name
|
||||
------- ----- ------ ------ ------- ------- -----------------
|
||||
1010 11178 B-A 4L01 cash Cash
|
||||
3010 13500 I-I 101a sales Sales
|
||||
3080 250 I-I 106 royalty Gross royalties
|
||||
3100 3286 I-I 108 income Other Income
|
||||
4020 3601 I-COGS 102-A2 merch Misc Merchandise
|
||||
4030 2100 I-COGS 102-A3 wages Salary and Wages
|
||||
4370 2 I-E 122 parking Business parking
|
||||
4380 41 I-E 122 travel Business travel
|
||||
4384 114 I-E 122 hotel Business hotel
|
||||
.DE
|
||||
.PP
|
||||
The following gives an example of table
|
||||
.BR journaladjust :
|
||||
.DM
|
||||
Account Debit Credit Format Taxline Name
|
||||
------- ------- ------- ------- ------- ---------------------
|
||||
1110 20000 B-A 4L06 Beginning Inventory
|
||||
1110 22130 B-A 4L06 Ending Inventory
|
||||
1310 0 B-A 4L09a Accum Depreciation
|
||||
1330 0 B-A 4L10a Accum Depletion
|
||||
1420 0 B-A 4L12a Accum Amortization
|
||||
4010 20000 I-COGS 102-A1 Beginning Inventory
|
||||
4080 22130 I-COGS 102-A4 Ending Inventory
|
||||
4170 0 I-E 121 Depreciation
|
||||
4180 0 I-E 118 Depletion
|
||||
4215 0 I-E 122 Amortization
|
||||
.DE
|
||||
.PP
|
||||
The command
|
||||
.B adjust
|
||||
then produces the table
|
||||
.B adjustedtrial
|
||||
by combining
|
||||
.B trialbalance
|
||||
with
|
||||
.BR journaladjust .
|
||||
In this example,
|
||||
.B adjustedtrial
|
||||
appears as follows:
|
||||
.DM
|
||||
Account Debit Credit Format Taxline Short Name
|
||||
------- ----- ------ ------ ------- ------- -----------------
|
||||
1010 11178 B-A 4L01 cash Cash
|
||||
1110 2130 B-A 4L06 inv Inventory
|
||||
1310 0 B-A 4L09a adeprec Accum Depreciation
|
||||
1330 0 B-A 4L10a adeplet Accum Depletion
|
||||
1420 0 B-A 4L12a aamort Accum Amortization
|
||||
3010 13500 I-I 101a sales Sales
|
||||
3080 250 I-I 106 royalty Gross royalties
|
||||
3100 3286 I-I 108 income Other Income
|
||||
4010 20000 I-COGS 102-A1 beginv Begin Inventory
|
||||
4020 3601 I-COGS 102-A2 merch Misc Merchandise
|
||||
4030 2100 I-COGS 102-A3 wages Salary and Wages
|
||||
4080 22130 I-COGS 102-A4 endinv Ending Inventory
|
||||
4170 0 I-E 121 deprec Depreciation
|
||||
4180 0 I-E 118 deplet Depletion
|
||||
4215 0 I-E 122 amor Amortization
|
||||
4370 2 I-E 122 parking Business parking
|
||||
4380 41 I-E 122 travel Business travel
|
||||
4384 114 I-E 122 hotel Business hotel
|
||||
.DE
|
||||
.SH "See Also"
|
||||
.B
|
||||
act,
|
||||
balance
|
||||
.SO adjust
|
||||
+136
@@ -0,0 +1,136 @@
|
||||
.TH append "" "" "/rdb Command"
|
||||
.PC "Add a row to a table and update index tables"
|
||||
\fBappend [\-h \-m[bhirs]] \fItable \fB[\fIkeycolumn ...\fB] < \fItableorrow\fR
|
||||
.PP
|
||||
.II "row^append to table"
|
||||
.II "table^append row"
|
||||
.II "append row to table"
|
||||
The command
|
||||
.B append
|
||||
appends the row in table
|
||||
.I tableorrow
|
||||
onto the end of
|
||||
.IR table .
|
||||
It also updates the appropriate index table so that the
|
||||
next search will find it.
|
||||
For the
|
||||
.I record
|
||||
method of indexing,
|
||||
.B append
|
||||
adds the new record's offset to the end of the index table.
|
||||
For the
|
||||
.I inverted
|
||||
method of indexing, it adds the record and then sorts the table.
|
||||
.SH Options
|
||||
.B append
|
||||
recognizes the following options:
|
||||
.IP \fB\-h\fR
|
||||
.I tableorrow
|
||||
has no
|
||||
.B /rdb
|
||||
head line and dash line.
|
||||
This option is useful when you only have a row to append to a table,
|
||||
but it does not have a head line.
|
||||
.IP \fB\-m[bhirs]\fR
|
||||
Use a fast-access method.
|
||||
See the manual page for
|
||||
.B search
|
||||
for a description of the fast-access methods and how to invoke them.
|
||||
.SH Example
|
||||
Consider the table
|
||||
.BR inventory ,
|
||||
which is defined as follows:
|
||||
.DM
|
||||
Item Amount Cost Value Description
|
||||
---- ------ ---- ----- -----------
|
||||
1 3 50 150 rubber gloves
|
||||
2 100 5 500 test tubes
|
||||
3 5 80 400 clamps
|
||||
4 23 19 437 plates
|
||||
5 99 24 2376 cleaning cloth
|
||||
6 89 147 13083 bunsen burners
|
||||
7 5 175 875 scales
|
||||
.DE
|
||||
.PP
|
||||
This table has an index table, called
|
||||
.BR record ,
|
||||
which appears as follows:
|
||||
.DM
|
||||
Offset
|
||||
--------
|
||||
76
|
||||
113
|
||||
147
|
||||
177
|
||||
207
|
||||
245
|
||||
283
|
||||
.DE
|
||||
.PP
|
||||
Finally, consider the table
|
||||
.BR newrecord ,
|
||||
which is as follows:
|
||||
.DM
|
||||
Item Amount Cost Value Description
|
||||
---- ------ ---- ----- -----------
|
||||
8 35 105 0 pipettes
|
||||
.DE
|
||||
.PP
|
||||
Note that
|
||||
.B newrecord
|
||||
has the same columnar layout as
|
||||
.BR inventory .
|
||||
.PP
|
||||
The following command appends
|
||||
.B newrecord
|
||||
onto the end of
|
||||
.BR inventory:
|
||||
.DM
|
||||
append -mr inventory < newrecord
|
||||
.DE
|
||||
.PP
|
||||
After
|
||||
.B append
|
||||
has done its work,
|
||||
.B inventory
|
||||
appears as follows:
|
||||
.DM
|
||||
Item Amount Cost Value Description
|
||||
---- ------ ---- ----- --------------
|
||||
1 3 50 150 rubber gloves
|
||||
2 100 5 500 test tubes
|
||||
3 5 80 400 clamps
|
||||
4 23 19 437 plates
|
||||
5 99 24 2376 cleaning cloth
|
||||
6 89 147 13083 bunsen burners
|
||||
7 5 175 875 scales
|
||||
8 35 105 0 pipettes
|
||||
.DE
|
||||
.PP
|
||||
.BR inventory 's
|
||||
index table now appears as follows:
|
||||
.DM
|
||||
Offset
|
||||
--------
|
||||
76
|
||||
113
|
||||
147
|
||||
177
|
||||
207
|
||||
245
|
||||
283
|
||||
313
|
||||
.DE
|
||||
.PP
|
||||
The new ``313'' entry in the secondary index table
|
||||
.B inventory.r
|
||||
is the offset to record 8 \(em that is,
|
||||
the number of bytes for the beginning of the file to record 8.
|
||||
.SH "See Also"
|
||||
.B
|
||||
delete,
|
||||
index,
|
||||
replace,
|
||||
search
|
||||
.R
|
||||
.SO append
|
||||
@@ -0,0 +1,46 @@
|
||||
.TH ascii "" "" "/rdb Command"
|
||||
.PC "Return the ASCII value of a character"
|
||||
\fBascii \fIcharacter...\fR
|
||||
.PP
|
||||
.II ASCII
|
||||
The command
|
||||
.B ascii
|
||||
converts each of the characters in its first argument
|
||||
to a space-delimited series of numbers.
|
||||
You can use this command to find the internal computer representation
|
||||
of a character.
|
||||
Any strings following the first are ignored.
|
||||
If you have spaces in your string, be sure to put
|
||||
quotation marks around them.
|
||||
.SH Example
|
||||
The command
|
||||
.DM
|
||||
ascii aA1
|
||||
.DE
|
||||
.PP
|
||||
produces:
|
||||
.DM
|
||||
97 65 49
|
||||
.DE
|
||||
.PP
|
||||
The command
|
||||
.DM
|
||||
ascii ' '
|
||||
.DE
|
||||
.PP
|
||||
produces:
|
||||
.DM
|
||||
32
|
||||
.DE
|
||||
.PP
|
||||
Note that the single space character, enclosed within apostrophes,
|
||||
is converted to its ASCII code in decimal (32).
|
||||
.SH "See Also"
|
||||
.B
|
||||
chr
|
||||
.R
|
||||
.br
|
||||
COHERENT Lexicon:
|
||||
.B
|
||||
ASCII
|
||||
.R
|
||||
@@ -0,0 +1,16 @@
|
||||
.TH backup "" "" "Technical Information"
|
||||
.PC
|
||||
.PP
|
||||
When you are using
|
||||
.B /rdb
|
||||
to store and manipulate your data, you must back up your data regularly.
|
||||
If you do not back up your data and your disk should fail for whatever
|
||||
reason, your data will be irretrievably lost.
|
||||
.PP
|
||||
See the COHERENT manual section 2, \fIUsing the COHERENT System\fR, for
|
||||
a detailed description of how to back up your data.
|
||||
Also see the Lexicon articles on
|
||||
.B ustar
|
||||
and
|
||||
.B cpio
|
||||
for descriptions of how to use these tools to back up your data.
|
||||
@@ -0,0 +1,71 @@
|
||||
.TH balance "" "" "/act/gl Command"
|
||||
.PC "Create balance sheet from adjusted trial balance"
|
||||
.B balance
|
||||
.PP
|
||||
.II "balance sheet"
|
||||
The command
|
||||
.B balance
|
||||
is part of the accounting/general-ledger system included with
|
||||
.BR /rdb .
|
||||
It reads table
|
||||
.B adjustedtrial
|
||||
and writes a balance sheet into table
|
||||
and writes it into file
|
||||
.BR balancesheet .
|
||||
.SH Example
|
||||
Consider the table
|
||||
.BR adjustedtrial ,
|
||||
as follows:
|
||||
.DM
|
||||
Account Debit Credit Format Taxline Short Name
|
||||
------- ----- ------ ------ ------- ------- ------------------
|
||||
1010 11178 B-A 4L01 cash Cash
|
||||
1110 2130 B-A 4L06 inv Inventory
|
||||
1310 0 B-A 4L09a adeprec Accum Depreciation
|
||||
1330 0 B-A 4L10a adeplet Accum Depletion
|
||||
1420 0 B-A 4L12a aamort Accum Amortization
|
||||
3010 13500 I-I 101a sales Sales
|
||||
3080 250 I-I 106 royalty Gross royalties
|
||||
3100 3286 I-I 108 income Other Income
|
||||
4010 20000 I-COGS 102-A1 beginv Begin Inventory
|
||||
4020 3601 I-COGS 102-A2 merch Misc Merchandise
|
||||
4030 2100 I-COGS 102-A3 wages Salary and Wages
|
||||
4080 22130 I-COGS 102-A4 endinv Ending Inventory
|
||||
4170 0 I-E 121 deprec Depreciation
|
||||
4180 0 I-E 118 deplet Depletion
|
||||
4215 0 I-E 122 amor Amortization
|
||||
4370 2 I-E 122 parking Business parking
|
||||
4380 41 I-E 122 travel Business travel
|
||||
4384 114 I-E 122 hotel Business hotel
|
||||
.DE
|
||||
.PP
|
||||
The command
|
||||
.B balance
|
||||
writes the balance sheet into
|
||||
.BR balancesheet ,
|
||||
which appears as follows:
|
||||
.DM
|
||||
Makeapile, Inc.
|
||||
31 December 1985
|
||||
Balancesheet
|
||||
.DE
|
||||
.DM
|
||||
11178 Cash
|
||||
2130 Inventory
|
||||
0 Accumulated Depreciation
|
||||
0 Accumulated Depletion
|
||||
0 Accumulated Amortization
|
||||
----- ------------------------
|
||||
13308 Total Assets
|
||||
.DE
|
||||
.DM
|
||||
13308 Retained Earnings (Profit)
|
||||
------ --------------------------
|
||||
13308 Total Liabilities and Equity
|
||||
.DE
|
||||
.SH "See Also"
|
||||
.B
|
||||
act,
|
||||
adjust
|
||||
.R
|
||||
.SO balance
|
||||
@@ -0,0 +1,71 @@
|
||||
.TH blank "" "" "/rdb Command"
|
||||
.PC "Replace all data in a record with spaces"
|
||||
\fBblank < \fItableorlist\fR
|
||||
.PP
|
||||
.II "blank a row"
|
||||
.II "row^blank out"
|
||||
The command
|
||||
.B blank
|
||||
replaces with spaces every values in each record of
|
||||
.IR tableorlist .
|
||||
.PP
|
||||
The command
|
||||
.B update
|
||||
uses
|
||||
.B blank
|
||||
when it updates a record.
|
||||
.B update
|
||||
temporarily replaces the record it is updating with a blank record.
|
||||
This blank record serves as a record lock; this ensures
|
||||
that other users cannot read
|
||||
or update the record while it is being updated, but it leaves the
|
||||
rest of the table available for use.
|
||||
.PP
|
||||
Please note that when you pull up a blank record,
|
||||
it means that that record is being updated by someone else.
|
||||
Come back to it later.
|
||||
.SH Example
|
||||
To blank out the data fields in table
|
||||
.B maillist
|
||||
and then
|
||||
.B see
|
||||
the result, you could type the following:
|
||||
.DM
|
||||
blank < maillist | see
|
||||
.DE
|
||||
.PP
|
||||
This command produces the following output:
|
||||
.DM
|
||||
Number^I $
|
||||
Name^I $
|
||||
Company^I $
|
||||
Street^I $
|
||||
City^I $
|
||||
State^I $
|
||||
ZIP^I $
|
||||
Phone^I $
|
||||
$
|
||||
Number^I $
|
||||
Name^I $
|
||||
Company^I $
|
||||
Street^I $
|
||||
City^I $
|
||||
State^I $
|
||||
ZIP^I $
|
||||
Phone^I $
|
||||
.DE
|
||||
.PP
|
||||
Note the spaces between the tab (^I) and the dollar sign `$'
|
||||
that indicates the end of the line.
|
||||
The spaces replaced the
|
||||
characters, including spaces, that were in the original records.
|
||||
.PP
|
||||
Note too that the column names are untouched, so that this
|
||||
is a perfectly correct file as far as the
|
||||
.B /rdb
|
||||
commands are concerned, it just contains no data.
|
||||
.SH "See Also"
|
||||
.B
|
||||
see,
|
||||
update
|
||||
.R
|
||||
+82
@@ -0,0 +1,82 @@
|
||||
.TH bom "" "" "/act/opr Command"
|
||||
.PC "Produce bill-of-materials from parts list"
|
||||
.B bom
|
||||
.PP
|
||||
.II "bill of materials"
|
||||
The command
|
||||
.B bom
|
||||
is part of the accounting/operations system included with
|
||||
.BR /rdb .
|
||||
It creates a bill-of-materials table from table
|
||||
.BR part ,
|
||||
which holds all of the items that are required to make a product,
|
||||
and the table
|
||||
.BR saleitem ,
|
||||
which holds all sales items from the sales department.
|
||||
This tells how many items must be manufactured or purchased
|
||||
to meet current sales orders.
|
||||
.PP
|
||||
.B bom
|
||||
writes its output into table
|
||||
.BR bom .
|
||||
.SH Example
|
||||
Assume the table
|
||||
.B saleitem
|
||||
contains the following data:
|
||||
.DM
|
||||
Order Number Code Backord Qty Price Total Name
|
||||
----- ------ ---- ------- --- ----- ------- ----
|
||||
1 1 rdb 10 1 1500 1500.00 /rdb
|
||||
2 1 rdb 10 2 1500 3000.00 /rdb
|
||||
3 1 rdb 10 5 1500 7500.00 /rdb
|
||||
3 2 act 10 10 1500 15000.00 /act
|
||||
4 1 rdb 10 5 1500 7500.00 /rdb
|
||||
4 2 rdb 10 19 1500 28500.00 /rdb
|
||||
5 1 rdb 10 5 1500 7500.00 /rdb
|
||||
5 2 act 10 9 1500 13500.00 /act
|
||||
.DE
|
||||
.PP
|
||||
Assume, too, that the table
|
||||
.B part
|
||||
contains the following
|
||||
data:
|
||||
.DM
|
||||
Code Subpart Count
|
||||
------- ------- -------
|
||||
act binder 2
|
||||
act actdoc 2
|
||||
act f1 10
|
||||
rdb binder 2
|
||||
rdb rdbdoc 2
|
||||
rdb f1 10
|
||||
.DE
|
||||
.PP
|
||||
The command
|
||||
.B bom
|
||||
reads these tables to produce the following summary table:
|
||||
.DM
|
||||
Code Qty
|
||||
------- -------
|
||||
actdoc 38
|
||||
binder 112
|
||||
f1 560
|
||||
rdbdoc 74
|
||||
.DE
|
||||
.PP
|
||||
You can see that we have orders for 19 copies of
|
||||
.BR act s
|
||||
in the
|
||||
.B salesitem
|
||||
table.
|
||||
Each package has two documents, for a total of 38
|
||||
.BR actdoc s.
|
||||
Note that table
|
||||
.B bom
|
||||
lists 560 floppies ((19 act x 10) + (37 rdb x 10)).
|
||||
We can order these, regardless
|
||||
of which software packages are being put onto them.
|
||||
.SH "See Also"
|
||||
.B
|
||||
act
|
||||
.R
|
||||
.SO bom
|
||||
@@ -0,0 +1,38 @@
|
||||
.TH calcpay "" "" "/act/pay Command"
|
||||
.PC "Post payroll to ledgerpay"
|
||||
.B calcpay
|
||||
.PP
|
||||
.II "post payroll"
|
||||
.II "payroll^calculate"
|
||||
The command
|
||||
.B calcpay
|
||||
is part of the accounting/payroll system that is included with
|
||||
.BR /rdb .
|
||||
It posts the payroll-journal table
|
||||
.B journalpay
|
||||
to the payroll-ledger table
|
||||
.BR ledgerpay .
|
||||
This ledger groups the pay checks by employee, and is used to create
|
||||
the W2 form.
|
||||
.SH Example
|
||||
Assume that table
|
||||
.B journalpay
|
||||
has the following data:
|
||||
.DM
|
||||
Date Number Hours Salary Rate Gross Federal State Net
|
||||
---- ------- ------ ------ ---- ------ ------- ----- ---
|
||||
860518 1 80 1000 0 1000 70 10 920
|
||||
860518 2 80 0 10 800 42 6 752
|
||||
860518 3 30 0 10 300 0 0 300
|
||||
.DE
|
||||
.PP
|
||||
Typing
|
||||
.B calcpay
|
||||
copies it to table
|
||||
.BR calcpay .
|
||||
.SH "See Also"
|
||||
.B
|
||||
act,
|
||||
getjournal
|
||||
.R
|
||||
.SO calcpay
|
||||
@@ -0,0 +1,30 @@
|
||||
.TH calculate "" "" "/act/gl Command"
|
||||
.PC "Compute each tax form listed"
|
||||
\fBcalculate \fItaxform ...\fR
|
||||
.PP
|
||||
.II "tax form^calculate"
|
||||
.II "calculate tax form"
|
||||
The command
|
||||
.B calculate
|
||||
is part of the accounting/general-ledger system that is included with
|
||||
.BR /rdb .
|
||||
It is a simple shell script that calculates each tax form
|
||||
listed on its command line.
|
||||
.SH Example
|
||||
The following command calculates the IRS 1040 form
|
||||
.DM
|
||||
calculate 1040
|
||||
.DE
|
||||
.SH "See Also"
|
||||
.B
|
||||
act,
|
||||
fillform
|
||||
.R
|
||||
.SH Notes
|
||||
Please note that the tax tables included with
|
||||
.B /rdb
|
||||
are from 1987.
|
||||
They are included solely to serve as examples, and no claim is made as to
|
||||
their accuracy when calculating current taxes.
|
||||
.IR "Caveat utilitor" .
|
||||
.SO calculate
|
||||
+54
@@ -0,0 +1,54 @@
|
||||
.TH cap "" "" "/rdb Command"
|
||||
.PC "Convert first letter of each word to upper case"
|
||||
\fBcap < \fItextfile\fR
|
||||
.PP
|
||||
.II "text^capitalize"
|
||||
.II "capitalize text"
|
||||
The command
|
||||
.B cap
|
||||
capitalizes the first letter of each word in
|
||||
.IR textfile .
|
||||
It writes its results to the standard output.
|
||||
.SH Example
|
||||
Assume that table
|
||||
.B Inventory
|
||||
has the following data:
|
||||
.DM
|
||||
Item Amount Cost Value Description
|
||||
---- ------ ---- ----- --------------
|
||||
1 3 50 150 rubber gloves
|
||||
2 100 5 500 test tubes
|
||||
3 5 80 400 clamps
|
||||
4 23 19 437 plates
|
||||
5 99 24 2376 cleaning cloth
|
||||
6 89 147 13083 bunsen burners
|
||||
7 5 175 875 scales
|
||||
.DE
|
||||
.PP
|
||||
As you can see, the column
|
||||
.B Descriptions
|
||||
has consists of words all in lower case.
|
||||
To capitalize the first letter of each word in
|
||||
.B Inventory
|
||||
file, type:
|
||||
.DM
|
||||
cap < Inventory
|
||||
.DE
|
||||
.PP
|
||||
This writes the following on the screen:
|
||||
.DM
|
||||
Item Amount Cost Value Description
|
||||
---- ------ ---- ----- --------------
|
||||
1 3 50 150 Rubber Gloves
|
||||
2 100 5 500 Test Tubes
|
||||
3 5 80 400 Clamps
|
||||
4 23 19 437 Plates
|
||||
5 99 24 2376 Cleaning Cloth
|
||||
6 89 147 13083 Bunsen Burners
|
||||
7 5 175 875 Scales
|
||||
.DE
|
||||
.SH "See Also"
|
||||
.B
|
||||
lowercase,
|
||||
uppercase
|
||||
.R
|
||||
@@ -0,0 +1,180 @@
|
||||
.TH cashflow "" "" "/rdb Command"
|
||||
.PC "Compute balance column of cash table"
|
||||
\fBcashflow < \fIcashtable\fR
|
||||
.PP
|
||||
.II "compute cash flow"
|
||||
.II "cash flow"
|
||||
The command
|
||||
.B cashflow
|
||||
helps you manage your cash flow.
|
||||
It reads
|
||||
.IR cashtable ,
|
||||
which you design,
|
||||
then computes a running balance in a
|
||||
.I Balance
|
||||
column (which must be column 3) from an
|
||||
.I Amount
|
||||
column (which must be column 2).
|
||||
.PP
|
||||
Cash-flow analysis lets you see if you will always have enough money
|
||||
in hand to cover each day's bills.
|
||||
It makes cash management possible by
|
||||
telling you whether to put off an expense until a check arrives,
|
||||
ask for an advance, get to work and make more money,
|
||||
or control your spending.
|
||||
.SH Example
|
||||
The following gives an example
|
||||
.IR cashtable ,
|
||||
called
|
||||
.BR cash :
|
||||
.DM
|
||||
Date Amount Balance Description
|
||||
------ ------ ------- -----------
|
||||
890101 512 current balance
|
||||
890101 -450 rent check
|
||||
890101 1000 pay check
|
||||
890115 -300 estimated tax payment
|
||||
890115 1000 pay check
|
||||
890115 -1000 living expenses
|
||||
890120 -900 big purchase
|
||||
.DE
|
||||
.DM
|
||||
890201 1000 pay check
|
||||
890201 -450 rent check
|
||||
890215 1000 pay check
|
||||
890115 -1000 living expenses
|
||||
.DE
|
||||
.PP
|
||||
The command
|
||||
.B cashflow
|
||||
needs two columns, named
|
||||
.B Amount
|
||||
and
|
||||
.B Balance.
|
||||
(If you use different column names, you must edit the
|
||||
.B cashflow
|
||||
shell script).
|
||||
All other columns are optional.
|
||||
Each row in your table represents
|
||||
a projected income item (positive) or a projected expense (negative).
|
||||
This is your flow of cash.
|
||||
To summarize the cash flow in our example table
|
||||
.BR cash ,
|
||||
type:
|
||||
.DM
|
||||
cashflow < cash
|
||||
.DE
|
||||
.PP
|
||||
This prints the following on your screen:
|
||||
.DM
|
||||
Date Amount Balance Description
|
||||
------ ------ ------- -----------
|
||||
890101 512 512 current balance
|
||||
890101 -450 62 rent check
|
||||
890101 1000 1062 pay check
|
||||
890115 -300 762 estimated tax payment
|
||||
890115 1000 1762 pay check
|
||||
890115 -1000 762 living expenses
|
||||
890120 -900 -138 big purchase
|
||||
.DE
|
||||
.DM
|
||||
890201 1000 862 pay check
|
||||
890201 -450 412 rent check
|
||||
890215 1000 1412 pay check
|
||||
890115 -1000 412 living expenses
|
||||
.DE
|
||||
.PP
|
||||
That
|
||||
.B "big purchase"
|
||||
gives us a negative balance in 890120.
|
||||
Now that you know, you can do something about it.
|
||||
One move is to put the big purchase off
|
||||
until the first of February.
|
||||
After you edit table
|
||||
.B cash
|
||||
to reflect this change, it appears as follows:
|
||||
.DM
|
||||
Date Amount Balance Description
|
||||
------ ------ ------- -----------
|
||||
890101 512 current balance
|
||||
890101 -450 rent check
|
||||
890101 1000 pay check
|
||||
890115 -300 estimated tax payment
|
||||
890115 1000 pay check
|
||||
890115 -1000 living expenses
|
||||
890201 1000 pay check
|
||||
890201 -900 big purchase
|
||||
890201 -450 rent check
|
||||
890215 1000 pay check
|
||||
890115 -1000 living expenses
|
||||
.DE
|
||||
.PP
|
||||
Running
|
||||
.B cashflow
|
||||
again will tell us if this strategy works:
|
||||
.DM
|
||||
Date Amount Balance Description
|
||||
------ ------ ------- -----------
|
||||
890101 512 512 current balance
|
||||
890101 -450 62 rent check
|
||||
890101 1000 1062 pay check
|
||||
890115 -300 762 estimated tax payment
|
||||
890115 1000 1762 pay check
|
||||
890115 -1000 762 living expenses
|
||||
890201 1000 1762 pay check
|
||||
890201 -900 862 big purchase
|
||||
890201 -450 412 rent check
|
||||
890215 1000 1412 pay check
|
||||
890115 -1000 412 living expenses
|
||||
.DE
|
||||
.PP
|
||||
As you can see, this works \(em there's no negative cash flow for any
|
||||
period.
|
||||
You can also try other options.
|
||||
.PP
|
||||
You can do all of the inputting and editing in the text editor.
|
||||
You can execute commands in
|
||||
.B vi
|
||||
by using the exclamation `!' shell feature;
|
||||
or from MicroEMACS by typing \fB<ctrl-X>!\fR.
|
||||
You also might want to write out to a
|
||||
.I tmp
|
||||
file and use
|
||||
.B mv
|
||||
to overwrite your
|
||||
.B cash
|
||||
table so that it is
|
||||
file is up to date.
|
||||
For example, in
|
||||
.B vi
|
||||
you can type:
|
||||
.DM
|
||||
:!cashflow < cashtable > tmp ; mv tmp cashtable
|
||||
:e!
|
||||
.DE
|
||||
.PP
|
||||
The first line computes the
|
||||
.B Balance
|
||||
column, writes the result into a
|
||||
.B tmp
|
||||
file, and moves
|
||||
.B tmp
|
||||
to be the new
|
||||
.B cashtable.
|
||||
All of this is necessary because
|
||||
in COHERENT you cannot have one file
|
||||
as both input and output without wiping out the file.
|
||||
The second line,
|
||||
.B :e!
|
||||
pulls the new file into the
|
||||
.B vi
|
||||
editor and displays it on your screen.
|
||||
.SH "See Also"
|
||||
COHERENT Lexicon:
|
||||
.B
|
||||
ksh,
|
||||
me,
|
||||
sh,
|
||||
vi
|
||||
.R
|
||||
.SO cashflow
|
||||
@@ -0,0 +1,25 @@
|
||||
.TH chartdup "" "" "/act/gl Command"
|
||||
.PC "Check for duplicate names and accounts in chart"
|
||||
.B chartdup
|
||||
.PP
|
||||
.II "duplicate name^check for"
|
||||
The command
|
||||
.B chartdup
|
||||
is part of the accounting/general-ledger system that is included with
|
||||
.BR /rdb .
|
||||
It checks to see if there are any duplicates among the
|
||||
account numbers or the short names within the chart of accounts.
|
||||
This is the most common error that people make when they update the
|
||||
chart of accounts.
|
||||
.SH Example
|
||||
The following gives example output of
|
||||
.BR chartdup :
|
||||
.DM
|
||||
Duplicate Account numbers in chart. See chart.Account
|
||||
4150 I-E 115 taxes Taxes
|
||||
4150 I-E 115 taxes Taxes
|
||||
Duplicate Short names in chart. See chart.Short
|
||||
4150 I-E 115 taxes Taxes
|
||||
4150 I-E 115 taxes Taxes
|
||||
.DE
|
||||
.SO chartdup
|
||||
@@ -0,0 +1,156 @@
|
||||
.TH check.rdb "" "" "/rdb Command"
|
||||
.PC "Report any rows in which columns do not match head line"
|
||||
\fBcheck.rdb < \fItableorlist\fR
|
||||
.PP
|
||||
.II "column^count"
|
||||
.II "count columns"
|
||||
.II "column^verify"
|
||||
.II "verify columns
|
||||
The command
|
||||
.B check.rdb
|
||||
counts the columns (number of tabs plus one) in the head line of an
|
||||
.B /rdb
|
||||
table or list formatted file.
|
||||
Then it displays information on each row that does not match
|
||||
the number of columns in the first head-line row.
|
||||
You should use it to see if your data entry is correct.
|
||||
If your head-line row is incorrect, then all of your rows will
|
||||
be reported as errors.
|
||||
.PP
|
||||
.B check.rdb
|
||||
returns zero when all is correct, and nonzero when
|
||||
it has found an error.
|
||||
You can use this status value (\fB$?\fR) in
|
||||
a shell script to take different actions, depending upon
|
||||
the validity of the table or list file.
|
||||
.SH Examples
|
||||
Here is a bad table, called
|
||||
.BR badtable :
|
||||
.DM
|
||||
Date Account Debit Credit Description
|
||||
------ ------- ------ ------ -----------
|
||||
820102 101 25000 cash from loan
|
||||
820102 211.1 25000 loan #378-14 Bank Amerigold
|
||||
820103 150.1 10000 test equipment from Zarkoff
|
||||
820103 101 5000 cash payment
|
||||
820103 211.2 5000 note payable to Zarkoff
|
||||
820104 130 30000 inventory - parts from CCPSC
|
||||
820104 201.1 15000 accounts payable to CCPSC
|
||||
820104 101 15000 cash payment to CCPSC for parts
|
||||
.DE
|
||||
.PP
|
||||
It is hard to see anything wrong with it.
|
||||
However, when we run the command
|
||||
.DM
|
||||
check.rdb < badtable
|
||||
.DE
|
||||
.PP
|
||||
we see the following output:
|
||||
.DM
|
||||
check.rdb: Columns (4) do not equal headline columns (5) in row 3 (line 5).
|
||||
820103 150.1 10000 test equipment from Zarkoff
|
||||
.DE
|
||||
.PP
|
||||
The command
|
||||
.DM
|
||||
see < badtable
|
||||
.DE
|
||||
.PP
|
||||
gives us the following output:
|
||||
.DM
|
||||
Date^IAccount^IDebit^ICredit^IDescription$
|
||||
----^I ------^I-----^I------^I-----------$
|
||||
820102^I101^I25000^I^Icash from loan$
|
||||
820102^I211.1^I^I25000^Iloan number #378-14 Bank Amerigold$
|
||||
820103^I150.1\ \ \ 10000^I^Itest equipment from Zarkoff$
|
||||
820103^I101^I^I5000^Icash payment$
|
||||
820103^I211.2^I^I5000^Inote payable to Zarkoff Equipment$
|
||||
820104^I130^I30000^I^Iinventory - parts from CCPSC$
|
||||
820104^I201.1^I^I15000^Iaccounts payable to CCPSC^I$
|
||||
820104^I101^I15000^I^Icash payment to CCPSC for parts$
|
||||
.DE
|
||||
.PP
|
||||
Note that a tab is missing from row 3 (line 5) of
|
||||
.BR badtable ,
|
||||
between values 150.1 and 10000.
|
||||
The spaces hide the fact that it is missing.
|
||||
.PP
|
||||
When you work with a large file, run
|
||||
.B check.rdb
|
||||
first.
|
||||
It will find the tab problems and give you the information you need to
|
||||
find them.
|
||||
Then use a text editor to correct the problem.
|
||||
.\"When using
|
||||
.\".BR vi ,
|
||||
.\"turn on the number
|
||||
.\"option so you can see line numbers:
|
||||
.\".DM
|
||||
.\" vi table
|
||||
.\".sp
|
||||
.\" :set number
|
||||
.\".DE
|
||||
.PP
|
||||
You can move down to the first bad line by typing the following
|
||||
.B vi
|
||||
command
|
||||
.BR :5 .
|
||||
This takes you to line 5.
|
||||
Then to see the line, type the list command
|
||||
.BR l: .
|
||||
(This is the letter
|
||||
.BR el ,
|
||||
not the number one).
|
||||
Or to do it in one step (move and list), type
|
||||
.BR :5l .
|
||||
Or you can using the following colon command
|
||||
to set all of the lines in the file to display tabs:
|
||||
.DM
|
||||
:set list
|
||||
.DE
|
||||
.PP
|
||||
To return it to normal display, use the command:
|
||||
.DM
|
||||
:set nolist
|
||||
.DE
|
||||
.PP
|
||||
Edit in whatever changes you need, then go to the next bad line.
|
||||
You can change a space to a tab with the following command:
|
||||
.DM
|
||||
:s/ /^I/
|
||||
.DE
|
||||
.PP
|
||||
where the
|
||||
.B ^I
|
||||
is the key on your keyboard that produces a tab.
|
||||
If you want to list three lines above and below the bad line, type:
|
||||
.DM
|
||||
:-3,+3l
|
||||
.DE
|
||||
.PP
|
||||
If you use \fBve\fP to enter your data, you will
|
||||
have fewer problems like this.
|
||||
Data from foreign sources should
|
||||
be checked carefully before you use it with \fB/rdb\fR.
|
||||
.SH "See Also"
|
||||
.B
|
||||
see,
|
||||
ve
|
||||
.R
|
||||
.br
|
||||
COHERENT Lexicon:
|
||||
.B
|
||||
elvis,
|
||||
me,
|
||||
vi
|
||||
.R
|
||||
.SH Notes
|
||||
This command is named
|
||||
.B check.rdb
|
||||
rather than
|
||||
.BR check ,
|
||||
as in other implementations of
|
||||
.BR /rdb ,
|
||||
to avoid clashing with the COHERENT command
|
||||
.BR check ,
|
||||
which does something very different.
|
||||
+41
@@ -0,0 +1,41 @@
|
||||
.TH chr "" "" "/rdb Command"
|
||||
.PC "Display the character corresponding to a number"
|
||||
\fBchr \fInumber ...\fR
|
||||
.PP
|
||||
.II "integer^convert to ASCII"
|
||||
.II "convert integer to ASCII"
|
||||
.II "ASCII^convert from integer"
|
||||
.B chr
|
||||
converts each of the integers on
|
||||
its command line to its corresponding ASCII character.
|
||||
You can use it to send special characters to the screen.
|
||||
This gives you a good way to produce special characters that are
|
||||
hard to type or are interpreted by the shell.
|
||||
.SH Example
|
||||
Here we convert several characters.
|
||||
.DM
|
||||
chr 97 65 49
|
||||
aA1
|
||||
.DE
|
||||
.DM
|
||||
chr 7
|
||||
[beep]
|
||||
.DE
|
||||
.DM
|
||||
echo `chr 7`Wake up
|
||||
[beep]Wake up
|
||||
.DE
|
||||
.PP
|
||||
The
|
||||
.B [beep]
|
||||
is the sound.
|
||||
It does not print on your terminal.
|
||||
.SH "See Also"
|
||||
.B
|
||||
ascii
|
||||
.R
|
||||
.br
|
||||
COHERENT Lexicon:
|
||||
.B
|
||||
ASCII
|
||||
.R
|
||||
@@ -0,0 +1,95 @@
|
||||
.TH clear.rdb "" "" "/rdb Command"
|
||||
.PC "Clear the terminal's screen"
|
||||
.B clear.rdb
|
||||
.PP
|
||||
.II "screen^clear"
|
||||
.II "clear screen"
|
||||
The command
|
||||
.B clear.rdb
|
||||
clears your terminal screen of all characters and leaves the
|
||||
cursor in the upper left corner.
|
||||
It is useful for menus and forms that look better on a clear
|
||||
screen.
|
||||
.PP
|
||||
.II termcap
|
||||
.II TERM
|
||||
.B clear.rdb
|
||||
uses the
|
||||
.B termcap
|
||||
file of terminal capabilities to find the string of special
|
||||
characters that are needed to clear your screen.
|
||||
To work correctly, the
|
||||
.B TERM
|
||||
environmental variable must be set correctly to the name of your
|
||||
terminal as listed in
|
||||
.BR /etc/termcap .
|
||||
.PP
|
||||
The COHERENT command
|
||||
.B clear.rdb
|
||||
also clears the screen.
|
||||
.PP
|
||||
The
|
||||
.B /rdb
|
||||
command
|
||||
.B termput
|
||||
can also clear the screen, as follows:
|
||||
.DM
|
||||
termput cl
|
||||
.DE
|
||||
.\".PP
|
||||
.\"The difference is that
|
||||
.\".B termput
|
||||
.\"uses
|
||||
.\".BR /etc/termcap ,
|
||||
.\"whereas
|
||||
.\".B tput
|
||||
.\"use the
|
||||
.\".I terminfo
|
||||
.\"directory.
|
||||
.SH Speed
|
||||
.B clear.rdb
|
||||
is quite fast, but there is a much faster way.
|
||||
Set a shell variable
|
||||
.B CLEAR
|
||||
to the output of the command
|
||||
.B clear.rdb
|
||||
like this:
|
||||
.DM
|
||||
export CLEAR=`clear`
|
||||
.DE
|
||||
.PP
|
||||
Then you can use:
|
||||
.DM
|
||||
echo "$CLEAR"
|
||||
.DE
|
||||
.PP
|
||||
in your shell programs for a fast clear.
|
||||
Put it into your
|
||||
.B .profile
|
||||
so that it will always be available.
|
||||
Use quotation marks around the shell variables in case they
|
||||
have special characters in them.
|
||||
.SH "See Also"
|
||||
.B
|
||||
termput
|
||||
.R
|
||||
.br
|
||||
COHERENT Lexicon:
|
||||
.B
|
||||
clear,
|
||||
export,
|
||||
\&.profile,
|
||||
sh,
|
||||
TERM,
|
||||
termcap
|
||||
.R
|
||||
.SH Notes
|
||||
This command is named
|
||||
.B clear.rdb
|
||||
rather than
|
||||
.BR clear ,
|
||||
as in other implementations of
|
||||
.BR /rdb ,
|
||||
to avoid clashing with the COHERENT command
|
||||
.BR clear .
|
||||
.SO clear
|
||||
@@ -0,0 +1,36 @@
|
||||
.TH close "" "" "/act/gl Command"
|
||||
.PC "Close accounting period creating journal for next"
|
||||
.B close
|
||||
.PP
|
||||
.II "accounting period^close"
|
||||
.II ledger^close
|
||||
The command
|
||||
.B close
|
||||
is part of the accounting/general-ledger system that is included with
|
||||
.BR /rdb .
|
||||
It closes an accounting period, such as a month, quarter, or year, and
|
||||
creates the next period's journal, the table
|
||||
.BR journalnext .
|
||||
When you start the next period, carry the
|
||||
.B journalnext
|
||||
forward by \fBmv\fRing it to file
|
||||
.BR journallast .
|
||||
.SH Example
|
||||
The command
|
||||
.B close
|
||||
creates a file whose output resembles the following:
|
||||
.DM
|
||||
Account Date Debit Credit Ref Description
|
||||
------- ------- ----- ------ ------- ---------------
|
||||
1010 850101 11178 jl brought forward
|
||||
1110 850101 22130 jl brought forward
|
||||
1310 850101 0 jl brought forward
|
||||
1330 850101 0 jl brought forward
|
||||
1420 850101 0 jl brought forward
|
||||
4997 850101 33308 jl brought forward
|
||||
.DE
|
||||
.SH "See Also"
|
||||
.B
|
||||
act
|
||||
.R
|
||||
.SO close
|
||||
+125
@@ -0,0 +1,125 @@
|
||||
.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
|
||||
@@ -0,0 +1,19 @@
|
||||
.TH commands "" "" "/rdb Command"
|
||||
.PC "Describe /rdb commands"
|
||||
.B commands
|
||||
.PP
|
||||
.II "command^show /rdb commands"
|
||||
The command
|
||||
.B commands
|
||||
displays a table of
|
||||
.B /rdb
|
||||
commands, with a one-line description and the syntax of each command.
|
||||
.SH "See Also"
|
||||
.B
|
||||
act,
|
||||
helpme,
|
||||
rdb,
|
||||
whatis,
|
||||
whatwill
|
||||
.R
|
||||
.SO commands
|
||||
@@ -0,0 +1,96 @@
|
||||
.TH compresss "" "" "/rdb Command"
|
||||
.PC "Squeeze out all leading and trailing blanks"
|
||||
\fBcompresss [-b] < \fItableorlist\fR
|
||||
.PP
|
||||
.II "table^compress"
|
||||
.II "compress table"
|
||||
The command
|
||||
.B compresss
|
||||
removes all leading and trailing blanks from every column or field in
|
||||
.IR tableorlist .
|
||||
You an use it to save disk space.
|
||||
.PP
|
||||
Please note that the name \fBcompresss\fR is not a typographical error.
|
||||
The command is spelled in this way to avoid collision with the
|
||||
COHERENT command
|
||||
.BR compress ,
|
||||
which behaves very differently from
|
||||
.BR compresss .
|
||||
.PP
|
||||
.B compresss
|
||||
is almost the opposite of the command
|
||||
.BR justify .
|
||||
Your files are not as pretty when compressed as they are when
|
||||
justified, but they are smaller \(em
|
||||
usually one third the size or less.
|
||||
Therefore, they take less disk space and are much faster to process;
|
||||
after all,
|
||||
most of the time used to execute data-base programs consists
|
||||
of moving data from the disk to the memory and, sometimes, back to
|
||||
the disk.
|
||||
.PP
|
||||
Multiple blanks that separate words are left alone.
|
||||
.SH Options
|
||||
.B compresss
|
||||
recognizes the following option:
|
||||
.IP \fB\-b\fR
|
||||
Drop blank lines.
|
||||
Don't use this option with list files!
|
||||
.SH Example
|
||||
For example, consider table
|
||||
.BR oldjournal ,
|
||||
which is as follows:
|
||||
.DM
|
||||
Date Account Debit Credit Description
|
||||
------ ------- ----- ------ -----------
|
||||
890102 101 25000 cash from loan
|
||||
890102 211.1 25000 loan number #378-14 Bank Amerigold
|
||||
890103 150.1 10000 test equipment from Zarkoff
|
||||
890103 101 5000 cash payment
|
||||
890103 211.2 5000 note payable to Zarkoff Equipment
|
||||
890104 130 30000 inventory - parts from CCPSC
|
||||
890104 201.1 15000 accounts payable to CCPSC
|
||||
890104 101 15000 cash payment to CCPSC for parts
|
||||
.DE
|
||||
.PP
|
||||
After we run the command
|
||||
.DM
|
||||
compresss <old.journal | see
|
||||
.DE
|
||||
.PP
|
||||
.B old.journal
|
||||
has no extra spaces.
|
||||
We prove this by piping the output to the
|
||||
.B /rdb
|
||||
command
|
||||
.BR see ,
|
||||
which displays the following output:
|
||||
.DM
|
||||
Date^IAccount^IDebit^ICredit^IDescription$
|
||||
----^I-------^I-----^I------^I-----------$
|
||||
890102^I101^I25000^I^Icash from loan$
|
||||
890102^I211.1^I^I25000^Iloan number #378-14 Bank Amerigold$
|
||||
890103^I150.1^I10000^I^Itest equipment from Zarkoff$
|
||||
890103^I101^I^I5000^Icash payment$
|
||||
890103^I211.2^I^I5000^Inote payable to Zarkoff Equipment$
|
||||
890104^I130^I30000^I^Iinventory - parts from CCPSC$
|
||||
890104^I201.1^I^I15000^Iaccounts payable to CCPSC$
|
||||
890104^I101^I^I15000^Icash payment to CCPSC for parts$
|
||||
.DE
|
||||
.PP
|
||||
Note that
|
||||
.B see
|
||||
turns all of the tabs into \fB^I\fR
|
||||
and puts a dollar sign `$' at the end of each row to show us that
|
||||
there are no spaces at the end.
|
||||
.SH "See Also"
|
||||
.B
|
||||
justify,
|
||||
rmblank
|
||||
.R
|
||||
.SH Notes
|
||||
Do not confuse this command with the COHERENT system's command
|
||||
.BR compress ,
|
||||
which produces binary output that cannot be read by any
|
||||
.B /rdb
|
||||
command.
|
||||
+364
@@ -0,0 +1,364 @@
|
||||
.TH compute "" "" "/rdb Command"
|
||||
.PC "Calculate columns of a table"
|
||||
\fBcompute '\fIcolumn \fB= \fIexpression \fB[ ; ... ]' < \fItableorlist\fR
|
||||
.PP
|
||||
.II "arithmetic^column"
|
||||
.II "column^arithmetic"
|
||||
.II "column^recompute"
|
||||
The command
|
||||
.B compute
|
||||
lets you to do arithmetic on columns.
|
||||
A column can be computed as a function of other columns, of itself,
|
||||
and of constants.
|
||||
.PP
|
||||
.B compute
|
||||
uses the COHERENT command
|
||||
.B awk
|
||||
to perform its work, as
|
||||
does the command
|
||||
.BR row .
|
||||
.B awk
|
||||
is a a powerful, interpreted programming language in which you can write
|
||||
programs to perform complex transformations on text.
|
||||
The advantage of
|
||||
.B compute,
|
||||
over
|
||||
.B awk
|
||||
is that
|
||||
.B compute
|
||||
knows about the names of columns in a table;
|
||||
this permits you to use column names instead of column positional numbers.
|
||||
(In
|
||||
.B awk
|
||||
the second column is named
|
||||
.BR $2 .)
|
||||
To grasp the full power of
|
||||
.B compute
|
||||
and
|
||||
.BR row ,
|
||||
read the COHERENT system's
|
||||
.B awk
|
||||
tutorial.
|
||||
If you must perform very complex manipulations of tables, use
|
||||
.BR awk .
|
||||
.PP
|
||||
If you must create a new empty column for
|
||||
.B compute
|
||||
to put values into, use the command
|
||||
.BR column .
|
||||
This command
|
||||
creates an empty column for any
|
||||
column it cannot find in the header line.
|
||||
.SH Example
|
||||
This example computes a column from other columns:
|
||||
.DM
|
||||
compute 'Value = sprintf("%5.2f", Cost * Amount)' < inventory
|
||||
.DE
|
||||
.DM
|
||||
Item Amount Cost Value Description
|
||||
---- ------ ----- ------ ---------------
|
||||
1 3 5.00 15.00 rubber gloves
|
||||
2 100 0.50 50.00 test tubes
|
||||
3 5 8.00 40.00 clamps
|
||||
4 23 1.98 45.54 plates
|
||||
5 99 2.45 242.55 cleaning cloth
|
||||
6 89 14.75 1312.75 bunsen burners
|
||||
7 5 175.00 875.00 scales
|
||||
.DE
|
||||
.PP
|
||||
Here are more examples of what you can do with compute.
|
||||
You can change the format of \fBcolumn\fR by using a C-style
|
||||
.BR sprintf :
|
||||
.DM
|
||||
compute 'column = sprintf ("%8.2f", column)' < tableorlist
|
||||
.DE
|
||||
.PP
|
||||
You can
|
||||
set \fBcolumn\fR equal to the length of the string in \fBcolumn2\fR:
|
||||
.DM
|
||||
compute 'column = length (column2)' < tableorlist
|
||||
.DE
|
||||
.PP
|
||||
You can also
|
||||
Set \fBcolumn\fR equal to the natural logarithm of \fBcolumn2\fR:
|
||||
.DM
|
||||
compute 'column = sprintf("%f", log (column2))' < tableorlist
|
||||
.DE
|
||||
.PP
|
||||
Or, you can
|
||||
increment \fBcolumn2\fR whenever \fBcolumn\fR is greater than \fBnumber\fR:
|
||||
.DM
|
||||
compute 'if (column > number) column2 = \e
|
||||
sprintf("%d", column2+1)' < tableorlist
|
||||
.DE
|
||||
.SH Expressions
|
||||
As you can see, you can write rather complex expressions for
|
||||
.BR compute .
|
||||
By
|
||||
.I expression,
|
||||
we mean many kinds of equations.
|
||||
For example, a variable or a column is an expression.
|
||||
So is variable + variable. So are rather complex equations.
|
||||
The following symbols indicate some of the more complex expressions:
|
||||
.IP \fBcolumn\fR 0.3i
|
||||
Name of a column, exactly as it appears at the top of the column.
|
||||
.IP \fB\(eq\fR
|
||||
Make the column on the left equal the expression on the right.
|
||||
.IP \fB+\fR
|
||||
Add
|
||||
.IP \fB\-\fR
|
||||
Subtract
|
||||
.IP \fB*\fR
|
||||
Multiply
|
||||
.IP \fB/\fR
|
||||
Divide.
|
||||
.IP \fB%\fR
|
||||
Modulo (zero if left value is equally divisible by right).
|
||||
.IP \fB;\fR
|
||||
Statement separator needed if more than one equation
|
||||
.IP \fBlog()\fR
|
||||
Natural logarithm of value or column within parentheses.
|
||||
.IP \fBlength()\fR
|
||||
String length of string in column.
|
||||
.PP
|
||||
You can also use C language-like statements:
|
||||
.IP "\fBif (\fIexpression\^\fB) \fIequation\fB [ else \fIequation\fB ];\fR"
|
||||
For example:
|
||||
.DM
|
||||
if (Value > 10000) Status = "Special"; else Status = "Normal";
|
||||
.DE
|
||||
.IP "\fBwhile (\fIexpression\fB) \fIequation\fB;\fR
|
||||
For example:
|
||||
.DM
|
||||
while (column => 0) column -= 1 ;
|
||||
.DE
|
||||
.IP "\fBfor (\fIexpression\fB; \fIcondition\fB; \fIexpression\fB) \fIequation\fB;\fR"
|
||||
For example:
|
||||
.DM
|
||||
for (i = 0; i < column1; i++) array [i] = column2 + i ;
|
||||
.DE
|
||||
.PP
|
||||
You can also use the
|
||||
.B awk
|
||||
format \fIpattern \fB{ \fIaction \fB}\fR.
|
||||
For example:
|
||||
.DM
|
||||
compute 'length > 80 { print NR, "Line too long." }' < table
|
||||
.DE
|
||||
.PP
|
||||
.B awk
|
||||
recognizes
|
||||
.I length
|
||||
as a function that returns the length of the row and
|
||||
.B NR
|
||||
as the line number.
|
||||
Note that the line numbers of a file starts with the head line,
|
||||
while row numbers of a table starts after the dash line (line 3).
|
||||
.SH "What Is a Column Name?"
|
||||
.B compute
|
||||
looks up, in the column header of the input file,
|
||||
each word that it finds in its command-line program.
|
||||
If there is a match,
|
||||
.B compute
|
||||
converts the column name to its position (first, second, third, etc.)
|
||||
depending upon the relative location of the column.
|
||||
These column numbers are needed by
|
||||
.BR awk .
|
||||
.PP
|
||||
.B compute
|
||||
defines a column name to be a string of the following characters:
|
||||
.IP \fB1.\fR 0.3i
|
||||
Upper and lower letters, numbers, and the underscore `_'.
|
||||
.IP \fB2.\fR
|
||||
Any string that is enclosed by apostrophes or quotation marks.
|
||||
.PP
|
||||
Therefore, if you want special characters in your column names,
|
||||
put quotation marks around them when you use them.
|
||||
For example:
|
||||
.DM
|
||||
compute ' "Item#" = NR ' < inventory
|
||||
.DE
|
||||
.PP
|
||||
Note the quotation marks around the column head
|
||||
.B Item#
|
||||
because of the number character `#'.
|
||||
Also, note that we used quotation marks,
|
||||
because the whole program was enclosed in apostrophes.
|
||||
If you use one kind of mark around the whole program,
|
||||
use the other kind of mark around the column names
|
||||
that have special characters in them.
|
||||
.SH "Reserved Words to Avoid in Column Names"
|
||||
Some words are understood by
|
||||
.BR awk .
|
||||
Therefore, they should not be used in column names.
|
||||
A simple way to avoid a conflict is to start your column
|
||||
names with a capital letter.
|
||||
.B awk
|
||||
does not confuse
|
||||
.B Print
|
||||
with
|
||||
.BR print .
|
||||
Here is a list of
|
||||
.BR awk 's
|
||||
built-in functions.
|
||||
.nf
|
||||
.sp \n(pDu
|
||||
.ta 1.6i
|
||||
\fIReserved Words Description\fR
|
||||
.tc .
|
||||
\fBBEGIN\fR Pattern that matches before first input record
|
||||
\fBEND\fR Pattern that matches after last input record
|
||||
\fBbreak\fR Get out of for or while loop
|
||||
\fBcontinue\fR Go to next iteration of for or while loop
|
||||
\fBelse\fR Used in "if then else" expression
|
||||
\fBexit\fR Leave program entirely as if end of input
|
||||
\fBexp\fR Raise number to a power
|
||||
\fBfor\fR for ( expression ; condition ; expression ) statement
|
||||
\fBgetline\fR Get next input line
|
||||
\fBif\fR if ( condition ) statement [ else statement ]
|
||||
\fBin\fR for ( variable in array ) statement
|
||||
\fBindex\fR index ( string1, string2 )
|
||||
\fBint\fR Truncate argument to integer
|
||||
\fBlength\fR Return current line length, or length of argument
|
||||
\fBlog\fR Return log (to base 2) of argument
|
||||
\fBnext\fR Skip to next record and reexecute all commands
|
||||
\fBprint\fR Output variables
|
||||
\fBprintf\fR printf ("format", variable, ... )
|
||||
\fBsplit\fR split ( string, arrayname, separator)
|
||||
\fBsprintf\fR sprintf ("format", variable, ... )
|
||||
\fBsqrt\fR Return square root of argument
|
||||
\fBsubstr\fR substr ( string, start, number )
|
||||
\fBwhile\fR while ( condition ) statement
|
||||
.tc
|
||||
.fi
|
||||
.SH "Using Shell Variables in Programs"
|
||||
Often you want to use a shell variable in a
|
||||
.B compute
|
||||
command.
|
||||
It is easy, if you understand what is going on.
|
||||
For example, the following commands:
|
||||
.DM
|
||||
DATE=860101
|
||||
compute "Date = $DATE" < journal
|
||||
.DE
|
||||
.PP
|
||||
produce the following output:
|
||||
.DM
|
||||
Date Account Debit Credit Description
|
||||
------ ------- ----- ------ ----------------------------------
|
||||
860101 101 25000 cash from loan
|
||||
860101 211.1 25000 loan number #378-14 Bank Amerigold
|
||||
860101 150.1 10000 test equipment from Zarkoff
|
||||
860101 101 5000 cash payment
|
||||
860101 211.2 5000 note payable to Zarkoff Equipment
|
||||
860101 130 30000 inventory - parts from CCPSC
|
||||
860101 201.1 15000 accounts payable to CCPSC
|
||||
860101 101 15000 cash payment to CCPSC for parts
|
||||
.DE
|
||||
.PP
|
||||
We set a shell variable named
|
||||
.B DATE
|
||||
to a date.
|
||||
Then we used the variable in the
|
||||
.B compute
|
||||
command line program.
|
||||
But note that we had to use quotation marks (") instead of our
|
||||
usual apostrophes (').
|
||||
To the shell, apostrophes protect absolutely.
|
||||
With apostrophes, the shell would not see the dollar sign `$' in front of
|
||||
.B DATE
|
||||
and would not convert it to its value.
|
||||
The quotation mark protects the enclosed from the shell, also,
|
||||
except for shell variables and command substitution (`cmd`).
|
||||
With quotation marks, the shell will still replace variables
|
||||
(which start with a dollar sign character).
|
||||
.PP
|
||||
There is one further complication.
|
||||
The previous worked fine because the value of date was a number.
|
||||
But if we want to use strings in
|
||||
.BR awk ,
|
||||
they must have quotation marks (not apostrophes) around them.
|
||||
For example:
|
||||
.DM
|
||||
COMPANY='Makeapile, Inc.'
|
||||
compute "Company = \e"$COMPANY\e"" < maillist
|
||||
.DE
|
||||
.PP
|
||||
produces the following:
|
||||
.DM
|
||||
.ta 1.0i
|
||||
Number 1
|
||||
Name Ronald McDonald
|
||||
Company Makeapile, Inc.
|
||||
Street 123 Mac Attack
|
||||
City Memphis
|
||||
State TENN
|
||||
ZIP 30000
|
||||
Phone (111) 222-3333
|
||||
.DE
|
||||
.DM
|
||||
.ta 1.0i
|
||||
Number 2
|
||||
Name Chikeeta Banana
|
||||
Company Makeapile, Inc.
|
||||
Street Uno Avenito De La Revolution
|
||||
City San Jose
|
||||
State El Salvadore
|
||||
ZIP 123456789
|
||||
Phone 1234
|
||||
.DE
|
||||
.PP
|
||||
Here we set a shell variable
|
||||
.B COMPANY
|
||||
to a company name.
|
||||
We want to update the mail list because these characters
|
||||
have been hired by a new company.
|
||||
Note what we had to do.
|
||||
We needed quotation marks around the
|
||||
whole program to let the shell substitute the value of the
|
||||
shell variable.
|
||||
But we also needed quotation marks around
|
||||
the string ``Makeapile, Inc.'' for
|
||||
.BR awk .
|
||||
So we have to protect the innermost quotation marks with backslashes.
|
||||
.PP
|
||||
There is another way, which opens up a little window in
|
||||
the program for the shell to insert strings.
|
||||
But it fails when there are spaces in the window string.
|
||||
So use the method previously discussed.
|
||||
.SH "Problem With awk Floating-Point Format"
|
||||
With some implementations of
|
||||
.BR awk ,
|
||||
the value column is computed to much greater precision
|
||||
than you are likely to want.
|
||||
For example, version produces this table:
|
||||
.DM
|
||||
Item# Amount Cost Value Description
|
||||
------- ------- ------- ------- ---------------
|
||||
1 3 5.00 15 rubber gloves
|
||||
2 100 0.50 50 test tubes
|
||||
3 5 8.00 40 clamps
|
||||
4 23 1.98 45.539997100830078125 plates
|
||||
5 99 2.45 242.5499725341796875 cleaning cloth
|
||||
6 89 14.75 1312.75 bunsen burners
|
||||
7 5 175.00 875 scales
|
||||
.DE
|
||||
.PP
|
||||
To control the precision of the
|
||||
floating-point values in a column, you can use the
|
||||
.B sprintf
|
||||
function from the C programming language that has been implemented in
|
||||
.BR awk .
|
||||
For example:
|
||||
.DM
|
||||
compute 'Value = sprintf ("%7.2f", ( Cost * Amount ))' < inventory
|
||||
.DE
|
||||
.PP
|
||||
These commands will produce the first table under Examples, above.
|
||||
.SH "See Also"
|
||||
COHERENT Lexicon:
|
||||
.B
|
||||
awk,
|
||||
ksh,
|
||||
sh
|
||||
.R
|
||||
@@ -0,0 +1,78 @@
|
||||
.TH computedate "" "" "/rdb Command"
|
||||
.PC "Add given number of days to a date"
|
||||
\fBcomputedate \fIdate days\fR
|
||||
.PP
|
||||
.II "date^arithmetic"
|
||||
.II "arithmetic^date"
|
||||
The command
|
||||
.B computedate
|
||||
adds days to a date, and displays the new date.
|
||||
.I date
|
||||
must be the format \fIYYMMDD\fR;
|
||||
.I days
|
||||
can be negative or positive.
|
||||
.B computedate
|
||||
displays the new date in the same format.
|
||||
This is the best format for entering dates in a column
|
||||
because they sort correctly and take only six characters.
|
||||
.PP
|
||||
Internally,
|
||||
.B computedate
|
||||
converts the date to
|
||||
.BR julian ,
|
||||
adds days, then converts the date back to
|
||||
.BR gregorian .
|
||||
Suppose we want to know the date 45 days from March 31, 1989.
|
||||
We can type:
|
||||
.DM
|
||||
computedate 890331 45
|
||||
.DE
|
||||
.PP
|
||||
This command returns the string:
|
||||
.DM
|
||||
890515
|
||||
.DE
|
||||
.PP
|
||||
That is May 15, 1989.
|
||||
.PP
|
||||
Another trick is to combine the
|
||||
.B todaysdate
|
||||
and the
|
||||
.B computedate
|
||||
programs.
|
||||
.B todaysdate
|
||||
gives the date of today in the preferred format of \fIYYMMDD\fR.
|
||||
For example, the following command shows us the date 45 days from today:
|
||||
.DM
|
||||
computedate `todaysdate` 45
|
||||
.DE
|
||||
.SH "Data Validation"
|
||||
You can use
|
||||
.B computedate
|
||||
to validate a date.
|
||||
If you add zero days to a date and get a different date, then
|
||||
the original date was not valid.
|
||||
For example, let's test the 32nd day of January 1989:
|
||||
.DM
|
||||
computedate 890132 0
|
||||
.DE
|
||||
.PP
|
||||
This returns the string
|
||||
.B 890201
|
||||
or February 1, 1989.
|
||||
As we expected, we received a different date.
|
||||
We can test this with the following shell program:
|
||||
.DM
|
||||
if test $DATE = `computedate $DATE 0`
|
||||
then
|
||||
echo OK
|
||||
else
|
||||
echo Invalid DATE
|
||||
fi
|
||||
.DE
|
||||
.SH "See Also"
|
||||
.B
|
||||
gregorian,
|
||||
julian,
|
||||
todaysdate
|
||||
.R
|
||||
@@ -0,0 +1,64 @@
|
||||
.TH consolidate "" "" "/act/gl Command"
|
||||
.PC "Combine all subsidiary journals to general journal"
|
||||
\fBconsolidate \fInextdate\fR
|
||||
.PP
|
||||
.II "consolidate journals"
|
||||
.II "journal^consolidate"
|
||||
The command
|
||||
.B consolidate
|
||||
is part of the accounting/general-ledger system that is included with
|
||||
.BR /rdb .
|
||||
It assembles all of the subsidiary journals, such as
|
||||
.BR journalincome ,
|
||||
.BR journalexpense ,
|
||||
and
|
||||
.BR journaldeposit ,
|
||||
into the general journal named
|
||||
.BR journal .
|
||||
It also converts from single-entry to double-entry bookkeeping
|
||||
by totaling
|
||||
.B Debits
|
||||
and
|
||||
.B Credits
|
||||
and inserting counterbalancing adjustments to the cash account.
|
||||
It needs the
|
||||
.B nextdate
|
||||
for these accounts.
|
||||
.SH Example
|
||||
The command
|
||||
.DM
|
||||
consolidate $NEXTDATE
|
||||
.DE
|
||||
.PP
|
||||
writes into file
|
||||
.B journal
|
||||
data that resemble the following:
|
||||
.DM
|
||||
Date Account Debit Credit Ref Description
|
||||
------ ------ ------- ------- ------ ----------------------
|
||||
890101 4370 2 r parking at clients
|
||||
890103 4380 15 c115 shuttle bus to airport
|
||||
890104 4380 13 v meal
|
||||
890105 4380 13 c116 meal
|
||||
890106 4384 114 r hotel
|
||||
890118 3100 3286 c101 consulting
|
||||
890125 3080 250 c1459 book fees
|
||||
891231 1010 5858 double-entry
|
||||
891231 1010 17036 double-entry
|
||||
891231 3010 13500 deposit from sales/deposit
|
||||
891231 4020 3601 check from pur/check
|
||||
891231 4030 2100 payroll from pay/journalpay
|
||||
.DE
|
||||
.PP
|
||||
Note the double-entry adjustments, and the totals of journals
|
||||
from sales, purchasing, and pay departments.
|
||||
The
|
||||
.B Date
|
||||
came from the
|
||||
.B NEXTDATE
|
||||
shell variable, which you must set in your
|
||||
.B .profile.
|
||||
.SH "See Also"
|
||||
.B
|
||||
getjournal
|
||||
.R
|
||||
@@ -0,0 +1,47 @@
|
||||
.TH cpdir.rdb "" "" "/rdb Command"
|
||||
.PC "Copy one directory tree to another directory"
|
||||
\fBcpdir.rdb \fIfromdirectory todirectory\fR
|
||||
.PP
|
||||
.II cpdir
|
||||
.II "copy directory"
|
||||
.II directory^copy
|
||||
The command
|
||||
.B cpdir.rdb
|
||||
copies a directory tree \(em that is, all directories and
|
||||
their files \(em from
|
||||
.I fromdirectory
|
||||
to
|
||||
.IR todirectory .
|
||||
.PP
|
||||
.B cpdir.rdb
|
||||
uses the tar command in a special way.
|
||||
It is a shell program
|
||||
so you can read it and see how it does it.
|
||||
It performs almost exactly the same work as the COHERENT command
|
||||
.BR cpdir .
|
||||
.SH Example
|
||||
You might use this to back up a large directory:
|
||||
.DM
|
||||
cpdir.rdb /usr/rdb /usr/rdb.backup
|
||||
.DE
|
||||
.PP
|
||||
The following moves a directory to a preferred place:
|
||||
.DM
|
||||
cpdir.rdb /usr/he.left/goodstuff /usr/project/goodstuff
|
||||
.DE
|
||||
.SH "See Also"
|
||||
COHERENT Lexicon:
|
||||
.B
|
||||
cpdir,
|
||||
tar
|
||||
.R
|
||||
.SH Notes
|
||||
This command is named
|
||||
.B cpdir.rdb
|
||||
rather than
|
||||
.BR cpdir ,
|
||||
as in other implementations of
|
||||
.BR /rdb ,
|
||||
to avoid clashing with the COHERENT command
|
||||
.BR cpdir .
|
||||
.SO cpdir.rdb
|
||||
@@ -0,0 +1,63 @@
|
||||
.TH cstate "" "" "/act/sales"
|
||||
.PC "Produce customer statement"
|
||||
.B cstate
|
||||
.PP
|
||||
.II "customer statement"
|
||||
The command
|
||||
.B cstate
|
||||
is part of the accounting/sales system that is included with
|
||||
.BR /rdb .
|
||||
It generates the customer statement from the tables
|
||||
.B salesorder
|
||||
and
|
||||
.BR deposit .
|
||||
It shows what the customer has ordered and paid, and the net.
|
||||
The result is printed as a form to be sent to the customer as a bill.
|
||||
.SH Example
|
||||
The following gives an example of the output of
|
||||
.BR cstate :
|
||||
.DM
|
||||
Please enter customer number (or all or Return to exit): \fB3\fP
|
||||
Customer Statement
|
||||
------------------
|
||||
Makeapile, Inc., 123 Bigbucks Blvd., Dallas, TX 12345, 1-800-SOF-WARE
|
||||
.DE
|
||||
.DM
|
||||
Mailing Address for Customer Number 3
|
||||
.DE
|
||||
.DM
|
||||
Ms Ute Unix Ph.D. President
|
||||
.DE
|
||||
.DM
|
||||
UniUniUniUni Software Sellers
|
||||
12345 Nixuni Street
|
||||
Union, New Jersey 11111 USA
|
||||
.DE
|
||||
.DM
|
||||
Now Due and Payable is your balance of: 107550.00
|
||||
.DE
|
||||
.DM
|
||||
Details of Your Orders and Payments
|
||||
.DE
|
||||
.DM
|
||||
Cust Date Amount Ref
|
||||
---- ------ --------- ----
|
||||
3 850902 -6300.00 17
|
||||
3 850902 -14175.00 16
|
||||
3 850902 -22050.00 15
|
||||
3 850902 -23625.00 12
|
||||
3 850902 -37800.00 13
|
||||
3 850903 -12600.00 23
|
||||
3 860105 9000.00 3347
|
||||
---- ------ --------- ----
|
||||
-107550.00
|
||||
.DE
|
||||
.DM
|
||||
Please enter customer number (or all or Return to exit):
|
||||
.DE
|
||||
.SH "See Also"
|
||||
.B
|
||||
act,
|
||||
vstate
|
||||
.R
|
||||
.SO cstate
|
||||
+136
@@ -0,0 +1,136 @@
|
||||
.TH cursor "" "" "/rdb Command"
|
||||
.PC "Move the cursor to the row and column requested"
|
||||
\fBcursor \fIrow col \fB[ \fICURSOR \fB]\fR
|
||||
.PP
|
||||
.II cursor^move
|
||||
.II "move cursor"
|
||||
.II "reposition cursor"
|
||||
The command
|
||||
.B cursor
|
||||
move the cursor to screen position
|
||||
.I row
|
||||
and
|
||||
.IR column .
|
||||
You can
|
||||
.B cursor
|
||||
and the
|
||||
.B /rdb
|
||||
command
|
||||
.B clear.rdb
|
||||
to perform complex screen handling from within a shell script.
|
||||
You can paint your screen with cursor moves and
|
||||
.B echo
|
||||
commands;
|
||||
then use the
|
||||
.B read
|
||||
command to read the user's input; and finally use various
|
||||
COHERENT and
|
||||
.B /rdb
|
||||
commands to examine and confirm the input.
|
||||
You can also clear fields of the screen by moving the cursor
|
||||
and writing blanks.
|
||||
.PP
|
||||
You must give the row and column you want.
|
||||
.B cursor
|
||||
also needs the cursor movement (\fBcm\fR) entry from file
|
||||
.BR /etc/termcap .
|
||||
This can be given as an argument, but the easiest way
|
||||
is to set up the shell variable called
|
||||
.B CURSOR ;
|
||||
then
|
||||
.B cursor
|
||||
will find it in its environment automatically.
|
||||
To set up the
|
||||
.B CURSOR
|
||||
variable, do the following:
|
||||
.DM
|
||||
CURSOR=`termput cm`
|
||||
.DE
|
||||
.PP
|
||||
.\"On UNIX System 5 Release 2, use
|
||||
.\".B tput:
|
||||
.\".sp
|
||||
.\".nf
|
||||
.\"$ CURSOR=`tput cup`
|
||||
.\".fi
|
||||
.\".sp
|
||||
Another way is to use your text editor to find the entry in
|
||||
.B /etc/termcap
|
||||
and copy its
|
||||
.B cm
|
||||
entry for your terminal to your
|
||||
.BR .profile :
|
||||
.DM
|
||||
CURSOR=^[[%p1%d;%p2%dH
|
||||
.DE
|
||||
.PP
|
||||
This is the entry for the
|
||||
.B pc
|
||||
terminal.
|
||||
The uparrow bracket (^[) is the ESC character (\fB<ctrl-[>\fR).
|
||||
The function
|
||||
.I tgoto
|
||||
function from the
|
||||
.B termcap
|
||||
library
|
||||
converts it into the proper escape string.
|
||||
.SH Example
|
||||
The following moves the cursor to the middle of an 80-by-24 screen:
|
||||
.DM
|
||||
cursor 11 38
|
||||
.DE
|
||||
.SH Speed
|
||||
.B cursor
|
||||
is fast, but there is a much faster way.
|
||||
Set a shell variable like
|
||||
.B L22
|
||||
to move to the 22nd line:
|
||||
.DM
|
||||
L22=`cursor 23 0`
|
||||
.DE
|
||||
.PP
|
||||
Then you can use:
|
||||
.DM
|
||||
echo "$L22$MESSAGE\ec"
|
||||
.DE
|
||||
.PP
|
||||
in your shell programs for a fast cursor movement and to print a message.
|
||||
Note the quotation marks around the messages in case there are
|
||||
special characters.
|
||||
Also note the
|
||||
.IR \ec ,
|
||||
which tells
|
||||
.B echo
|
||||
not to print a carriage return.
|
||||
.\"In older versions of UNIX
|
||||
.\"it is
|
||||
.\".I -n
|
||||
.\"instead of
|
||||
.\".I \ec.
|
||||
.PP
|
||||
An even better trick is to use the shell feature that tests
|
||||
to see if a variable has been set and only gives it a value
|
||||
when it needs one:
|
||||
.DM
|
||||
echo "${L22:=`cursor 22 0`}$MESSAGE\ec"
|
||||
.DE
|
||||
.PP
|
||||
All of this magic causes the shell to check if
|
||||
.B L22
|
||||
has a value.
|
||||
If not, it executes the
|
||||
.B cursor
|
||||
command and assigns the value to
|
||||
.B L22.
|
||||
Then, if this line is called in a loop, the next time the
|
||||
value will have been set and will be about 20 times faster.
|
||||
.SH "See Also"
|
||||
.B
|
||||
termput
|
||||
.R
|
||||
.br
|
||||
COHERENT Lexicon:
|
||||
.B
|
||||
\&.profile,
|
||||
termcap
|
||||
.R
|
||||
@@ -0,0 +1,37 @@
|
||||
.TH "dash line" "" "" "/rdb Definition"
|
||||
.PC
|
||||
.PP
|
||||
The
|
||||
.I "dash line"
|
||||
is the second line in an
|
||||
.B /rdb
|
||||
table.
|
||||
It underscores each entry in the table's head line.
|
||||
Each entry in the dash line must be separated by a tab character.
|
||||
.SH Example
|
||||
The table
|
||||
.B inventory
|
||||
appears as follows:
|
||||
.DM
|
||||
Item Amount Cost Value Description New
|
||||
---- ------ ---- ----- -------------- -------
|
||||
1 3 50 150 rubber gloves
|
||||
2 100 5 500 test tubes
|
||||
3 5 80 400 clamps
|
||||
4 23 19 437 plates
|
||||
5 99 24 2376 cleaning cloth
|
||||
6 89 147 13083 bunsen burners
|
||||
7 5 175 875 scales
|
||||
.DE
|
||||
.PP
|
||||
The dash line is:
|
||||
.DM
|
||||
---- ------ ---- ----- -------------- -------
|
||||
.DE
|
||||
.PP
|
||||
Note that there is one entry in the dash line for each entry in the
|
||||
head line.
|
||||
.SH "See Also"
|
||||
.B
|
||||
head line, listtotable, tabletolist
|
||||
.R
|
||||
@@ -0,0 +1,55 @@
|
||||
.TH datatype "" "" "/rdb Command"
|
||||
.PC "Display the data type of each column selected"
|
||||
\fBdatatype [ \-l ] [ \fIcolumn ... \fB] < \fItable\fR
|
||||
.PP
|
||||
.II "data type"
|
||||
.II "type of data"
|
||||
The command
|
||||
.B datatype
|
||||
displays the type of data contained in each
|
||||
.IR column .
|
||||
If you do not name a
|
||||
.I column
|
||||
on the command line,
|
||||
.B datatype
|
||||
calculates and displays all of
|
||||
.IR table 's
|
||||
columns.
|
||||
.SH Options
|
||||
The \fB\-l\fR option tells
|
||||
.B datatype
|
||||
to print the entire contents of
|
||||
.IR table ,
|
||||
in addition to information about each
|
||||
.IR column .
|
||||
.SH Code
|
||||
.IP \fB\-1\fR
|
||||
Character strings with nonnumeric data.
|
||||
.IP \fB0\fR
|
||||
Integer number.
|
||||
.IP \fB1,2...\fR
|
||||
Floating-point number (number of digits to the right of the decimal).
|
||||
.SH Example
|
||||
The following shows a sample output of
|
||||
.BR datatype :
|
||||
.DM
|
||||
Int Char Float2 Float4
|
||||
--- ---- ------ ------
|
||||
1 a 1.2 1.1234
|
||||
745 zzzz 8.54 12.3
|
||||
--- ---- ------ ------
|
||||
0 -1 2 4
|
||||
.DE
|
||||
.PP
|
||||
Note that the
|
||||
.I Int
|
||||
column has only integers in it (code 0), the
|
||||
.I Char
|
||||
column has characters in it (code -1), and the two
|
||||
.I Float
|
||||
columns have different precisions (positive numbers codes).
|
||||
Note that the float precision is the maximum.
|
||||
.SH "See Also"
|
||||
.B
|
||||
ascii, chr, dbdict
|
||||
.R
|
||||
+261
@@ -0,0 +1,261 @@
|
||||
.TH "dBASE crossreference" "" "" "Technical Information"
|
||||
.PC
|
||||
.PP
|
||||
.II dBASE
|
||||
.II Ashton-Tate
|
||||
.II "Borland International"
|
||||
dBASE was developed and marketed by Ashton-Tate;
|
||||
this company was purchased recently by Borland International.
|
||||
.PP
|
||||
The following table gives the
|
||||
.B /rdb
|
||||
and \*(UX equivalents for most common dBASE commands.
|
||||
The slug in \fBbold\fR characters gives the dBASE command; the following
|
||||
description gives the
|
||||
equivalent in
|
||||
.B /rdb
|
||||
and \*(UX
|
||||
commands:
|
||||
.II "command^dBASE to /rdb"
|
||||
.nf
|
||||
.sp \n(pDu
|
||||
\fBACCEPT Comment TO Variable\fR
|
||||
.II echo
|
||||
.II read
|
||||
echo Comment ; read Variable
|
||||
.sp \n(pDu
|
||||
\fBAPPEND BLANK\fR
|
||||
echo >> Fileout
|
||||
.sp \n(pDu
|
||||
\fBAPPEND FROM Filename FOR Condition\fR
|
||||
.II row
|
||||
row 'Condition' < Filename >> Fileout
|
||||
.sp \n(pDu
|
||||
\fBBROWSE\fR
|
||||
.II more
|
||||
.II scat
|
||||
.II update
|
||||
more, scat, update, or any text editor
|
||||
.sp \n(pDu
|
||||
\fBCANCEL\fR
|
||||
.II stty
|
||||
DEL (any character set with \fBstty\fR)
|
||||
.sp \n(pDu
|
||||
\fBCHANGE Range FIELD Fieldname FOR Condition\fR
|
||||
.II compute
|
||||
compute 'Range && Condition {Fieldname = Value}' < Filein
|
||||
.sp \n(pDu
|
||||
\fBCLEAR\fR
|
||||
\fBCLEAR GETS\fR
|
||||
.II clear
|
||||
clear
|
||||
.sp \n(pDu
|
||||
\fBCONTINUE\fR
|
||||
.II continue
|
||||
continue [shell statement]
|
||||
.sp \n(pDu
|
||||
\fBCOPY TO Filename FIELD Fieldnames FOR Condition\fR
|
||||
.II row
|
||||
.II column
|
||||
row 'Condition' < Filein | column Fieldnames > Filename
|
||||
.sp \n(pDu
|
||||
\fBCOUNT FOR Condition TO Variable FOR Condition\fR
|
||||
row 'Condition' < Filein | tail +3 | wc -l
|
||||
.sp \n(pDu
|
||||
\fBCREATE Filename\fR
|
||||
.II vi
|
||||
.II ve
|
||||
> Filename ; vi Filename ; ve Filename ; cmd > Filename
|
||||
.sp \n(pDu
|
||||
\fBDELETE RECORD Number\fR
|
||||
.II sed
|
||||
.II tail
|
||||
(sed $NUM+1}q Filename ; tail +$NUM+3}) > tmp; mv tmp Fieldname
|
||||
.sp \n(pDu
|
||||
\fBDELETE NEXT Number\fR
|
||||
\fBDELETE ALL\fR
|
||||
.II mv
|
||||
sed 2q Filename > tmp ; mv tmp Filename
|
||||
.sp \n(pDu
|
||||
\fBDELETE NEXT Number FOR Condition\fR
|
||||
\fBDELETE FILE Fieldname\fR
|
||||
> Filename
|
||||
.sp \n(pDu
|
||||
\fBDISPLAY Range FOR Bedingung Field OFF\fR
|
||||
row 'Range && Dedingung' < Filename | column Fieldnames
|
||||
.sp \n(pDu
|
||||
\fBDISPLAY STRUCTURE\fR
|
||||
.II for
|
||||
for I in * do sed 2q; done
|
||||
.sp \n(pDu
|
||||
\fBDISPLAY MEMORY\fR
|
||||
.II df
|
||||
.II du
|
||||
df ; du
|
||||
.sp \n(pDu
|
||||
\fBDISPLAY FILES ON Disk LIKE Datatype\fR
|
||||
.II ls
|
||||
ls *Datatype ; ls Disk/*Datatype
|
||||
.sp \n(pDu
|
||||
\fB) Program\fR
|
||||
Program
|
||||
.sp \n(pDu
|
||||
\fBCASE Condition\fR
|
||||
.II case
|
||||
Condition) [shell case statement]
|
||||
.sp \n(pDu
|
||||
\fBOTHERWISE\fR
|
||||
*) [shell case statement]
|
||||
.sp \n(pDu
|
||||
\fBDO WHILE Condition CR ENDDO\fR
|
||||
.II while
|
||||
while Condition CR do done
|
||||
.sp \n(pDu
|
||||
\fBEDIT\fR
|
||||
vi, ve, update, ex, ed, me, other editors and commands
|
||||
.sp \n(pDu
|
||||
\fBECT\fR
|
||||
\fBENDDO\fR
|
||||
do [in shell while, until, for statements]
|
||||
.sp \n(pDu
|
||||
\fBERASE\fR
|
||||
clear
|
||||
.sp \n(pDu
|
||||
\fBFIND Text\fR
|
||||
/Text (in vi, ve, update)
|
||||
.sp \n(pDu
|
||||
\fBINDEX ON Fieldname TO Filename\fR
|
||||
.II index
|
||||
index Filename Fieldname ...
|
||||
.sp \n(pDu
|
||||
\fBUSE Filename INDEX Keyfield\fR
|
||||
.II search
|
||||
search Filename Keyfield
|
||||
.sp \n(pDu
|
||||
\fBINPUT Text To Variable\fR
|
||||
Variable=Text
|
||||
.sp \n(pDu
|
||||
\fBINSERT\fR
|
||||
sed ${NUM}q Filename; echo $RECORD; tail +$NUM Filename
|
||||
.sp \n(pDu
|
||||
\fBJOIN TO Filename FOR Condition FIELDS Fieldnames\fR
|
||||
.II jointable
|
||||
jointable Filename1 Filename2
|
||||
row 'Condition' < Filename2 | jointable Filename1 -
|
||||
column Fieldnames < Filename2 | jointable Filename1 -
|
||||
.sp \n(pDu
|
||||
\fBColumn,Row SAY Comment GET Variable PICTURE\fR
|
||||
.II tput
|
||||
tput Column ; tput Row ; echo Comment ; READ Variable
|
||||
.sp \n(pDu
|
||||
\fBGO\fR
|
||||
\fBGOTO\fR
|
||||
\fBGO RECORD n\fR
|
||||
ve nG
|
||||
.sp \n(pDu
|
||||
\fBGO Fieldname\fR
|
||||
ve /
|
||||
.sp \n(pDu
|
||||
\fBGO TOP\fR
|
||||
ve H
|
||||
.sp \n(pDu
|
||||
\fBGO BOTTOM\fR
|
||||
ve L
|
||||
.sp \n(pDu
|
||||
\fBIF Condition Statement2 ELSE Statement2 ENDIF\fR
|
||||
if Condition then Statement1 else Statement2 fi
|
||||
.sp \n(pDu
|
||||
\fBLOCATE FOR Condition\fR
|
||||
row 'Condition' < Filename
|
||||
.sp \n(pDu
|
||||
\fBLOOP\fR
|
||||
while, until, for [shell statements]
|
||||
.sp \n(pDu
|
||||
\fBMODIFY STRUCTURE\fR
|
||||
column New Fieldnames < Filename
|
||||
.sp \n(pDu
|
||||
\fBNOTE\fR
|
||||
\fBREMARK\fR
|
||||
: Old Comment
|
||||
# New Comment
|
||||
.sp \n(pDu
|
||||
\fBMOVE Old-Filename TO New-Filename\fR
|
||||
mv Old-Filename New-Filename
|
||||
.sp \n(pDu
|
||||
\fBREPLACE Range Fieldname WITH Expression FOR Condition\fR
|
||||
.II compute
|
||||
compute 'Fieldname = Expression' < Filename
|
||||
compute 'Range && Condition {Fieldname = Expression}' < Filename
|
||||
.sp \n(pDu
|
||||
\fBREPORT Form FOR Condition TO PRINT\fR
|
||||
.II report
|
||||
report Form < Filename
|
||||
row 'Condition' < Filename | report Form | print
|
||||
.sp \n(pDu
|
||||
\fBPACK\fR
|
||||
.II pack
|
||||
compress, uncompress [\*(UX]
|
||||
.sp \n(pDu
|
||||
\fBQUIT\fR
|
||||
\fB<ctrl-D>\fR
|
||||
.sp \n(pDu
|
||||
\fBREAD\fR
|
||||
.II read
|
||||
read Variable
|
||||
.sp \n(pDu
|
||||
\fBRECALL Condition\fR
|
||||
row 'Condition' < Filename
|
||||
.sp \n(pDu
|
||||
\fBRELEASE Variable\fR
|
||||
Variable=
|
||||
.sp \n(pDu
|
||||
\fBRESET\fR
|
||||
\fBRESTORE FROM Filename\fR
|
||||
\fBRETURN\fR
|
||||
.II return
|
||||
return [shell]
|
||||
.sp \n(pDu
|
||||
\fBSAVE TO Filename\fR
|
||||
\fBSELECT\fR
|
||||
row, column, etc.
|
||||
.sp \n(pDu
|
||||
\fBSET\fR
|
||||
.II set
|
||||
set [shell]
|
||||
.sp \n(pDu
|
||||
\fBSKIP\fR
|
||||
\fBSORT ON Fieldname TO Filename\fR
|
||||
sorttable Fieldname > Filename
|
||||
.sp \n(pDu
|
||||
\fBSTORE Expression TO Variable\fR
|
||||
Variable=`Expression`
|
||||
.sp \n(pDu
|
||||
\fBSUM Fieldname TO Variable FOR Condition\fR
|
||||
Variable=`row 'Condition' < Filename | column Fieldname`
|
||||
.sp \n(pDu
|
||||
\fBTOTAL ON Keyfield TO Filename FIELDS Fieldnames FOR Condition\fR
|
||||
.II subtotal
|
||||
row 'Condition' | subtotal Keyfield Fieldnames > Filename
|
||||
.sp \n(pDu
|
||||
\fBUPDATE FROM Filename ON Keyfield\fR
|
||||
update, vi, ve, replace, append, delete, etc.
|
||||
.sp \n(pDu
|
||||
\fBUSE Filename\fR
|
||||
cmd < Filename
|
||||
.sp \n(pDu
|
||||
\fBWAIT\fR
|
||||
wait [shell]
|
||||
.sp \n(pDu
|
||||
\fB@ Row,Column SAY expression\fR
|
||||
cursor Row Column; echo EXPRESSION
|
||||
ve screen and validation file
|
||||
.fi
|
||||
.PP
|
||||
All data-base systems have some method for
|
||||
importing text files.
|
||||
Sometimes you'll be able to
|
||||
use the header information that comes with
|
||||
.B /rdb
|
||||
tables,
|
||||
and sometimes you'll have to specify this information
|
||||
to the target system anyway.
|
||||
@@ -0,0 +1,46 @@
|
||||
.TH dbdict "" "" "/rdb Command"
|
||||
.PC "Print a data-base dictionary"
|
||||
\fBdbdict < \fItable\fR
|
||||
.PP
|
||||
.II "data dictionary"
|
||||
.II "column^position"
|
||||
.II "column^number"
|
||||
The command
|
||||
.B dbdict
|
||||
prints a table of two columns:
|
||||
The first gives the names of each field in
|
||||
.IR table ,
|
||||
and the second gives the field numbers.
|
||||
.SH Example
|
||||
For example, we might have a table named
|
||||
.I journal
|
||||
that looks like this:
|
||||
.DM
|
||||
Date Account Debit Credit Description
|
||||
------ ------- ----- ------ ----------------------------------
|
||||
861222 101 25000 cash from loan
|
||||
861222 211.1 25000 loan number #378-14 Bank Amerigold
|
||||
861223 150.1 10000 test equipment from Zarkoff
|
||||
861223 101 5000 cash payment
|
||||
861223 211.2 5000 note payable to Zarkoff Equipment
|
||||
861224 130 30000 inventory - parts from CCPSC
|
||||
861224 201.1 15000 accounts payable to CCPSC
|
||||
861224 101 15000 cash payment to CCPSC for parts
|
||||
.DE
|
||||
.PP
|
||||
The command
|
||||
.DM
|
||||
dbdict < journal
|
||||
.DE
|
||||
.PP
|
||||
produces the following:
|
||||
.DM
|
||||
field name
|
||||
----- ----
|
||||
1 Date
|
||||
2 Account
|
||||
3 Debit
|
||||
4 Credit
|
||||
5 Description
|
||||
.DE
|
||||
.SO dbdict
|
||||
@@ -0,0 +1,96 @@
|
||||
.TH delete "" "" "/rdb Command"
|
||||
.PC "Blank record and update index file"
|
||||
\fBdelete [-m[bhirs]] \fItable keycolumn ... \fB< \fIkeytable\fR
|
||||
.PP
|
||||
.II row^delete
|
||||
.II "delete row"
|
||||
The command
|
||||
.B delete
|
||||
writes a blank record on the row in
|
||||
.I table
|
||||
whose key matches the row in the
|
||||
.IR keytable .
|
||||
It also deletes the offset row in the appropriate fast-access
|
||||
offset table, or, in the case of the
|
||||
.B hash
|
||||
method, replaces the deleted offset with \-1.
|
||||
.PP
|
||||
Options
|
||||
.B \-m[bhirs]
|
||||
lets you select a type of fast-accessing to locate the row to delete.
|
||||
For information on the type of fast accessing that each option invokes,
|
||||
see the manual entry for
|
||||
.BR index .
|
||||
.SH Example
|
||||
Consider table
|
||||
.BR inventory ,
|
||||
which appears as follows:
|
||||
.DM
|
||||
Item Amount Cost Value Description
|
||||
---- ------ ---- ----- --------------
|
||||
1 3 50 150 rubber gloves
|
||||
2 100 5 500 test tubes
|
||||
3 5 80 400 clamps
|
||||
4 23 19 437 plates
|
||||
5 99 24 2376 cleaning cloth
|
||||
6 89 147 13083 bunsen burners
|
||||
7 5 175 875 scales
|
||||
.DE
|
||||
.PP
|
||||
The
|
||||
.B record
|
||||
index looks like this:
|
||||
.DM
|
||||
Offset
|
||||
--------
|
||||
76
|
||||
113
|
||||
147
|
||||
177
|
||||
207
|
||||
245
|
||||
283
|
||||
.DE
|
||||
.PP
|
||||
The following command deletes the first record
|
||||
.BR Item 1:
|
||||
.DM
|
||||
echo 1 | delete -mr inventory Item
|
||||
.DE
|
||||
.PP
|
||||
.B inventory
|
||||
now appears as follows:
|
||||
.DM
|
||||
Item Amount Cost Value Description
|
||||
---- ------ ---- ----- --------------
|
||||
|
||||
2 100 5 500 test tubes
|
||||
3 5 80 400 clamps
|
||||
4 23 19 437 plates
|
||||
5 99 24 2376 cleaning cloth
|
||||
6 89 147 13083 bunsen burners
|
||||
7 5 175 875 scales
|
||||
.DE
|
||||
.PP
|
||||
.B inventory.r
|
||||
now appears as follows:
|
||||
.DM
|
||||
Offset
|
||||
--------
|
||||
113
|
||||
147
|
||||
177
|
||||
207
|
||||
245
|
||||
283
|
||||
.DE
|
||||
.PP
|
||||
Note that we have blanked out the record and removed the
|
||||
offset.
|
||||
.SH "See Also"
|
||||
.B
|
||||
append,
|
||||
index,
|
||||
replace
|
||||
.R
|
||||
.SO delete
|
||||
@@ -0,0 +1,88 @@
|
||||
.TH difference "" "" "/rdb Command"
|
||||
.PC "Output table of rows that are in only one table"
|
||||
\fBdifference \fItable1 table2\fR
|
||||
.PP
|
||||
.II table^difference
|
||||
.II table^subtract
|
||||
.II "subtract tables"
|
||||
.II sort
|
||||
.II uniq
|
||||
The command
|
||||
.B difference
|
||||
uses the COHERENT commands
|
||||
.B sort
|
||||
and
|
||||
.B uniq
|
||||
to subtract logically
|
||||
.I table2
|
||||
from
|
||||
.IR table1 .
|
||||
Its output consists of the rows that are in
|
||||
.I table1
|
||||
but not in
|
||||
.IR table2 .
|
||||
The two input tables must have the same columns
|
||||
(\fIunion compatible\fR in the technical data-base literature),
|
||||
and the rows must be exactly identical \(em including every space, tab,
|
||||
and nonprinting character.
|
||||
If two rows look the same to you but not to
|
||||
.BR difference ,
|
||||
try the
|
||||
.B see
|
||||
command to discover any blank spaces and nonprinting characters.
|
||||
.SH Example
|
||||
In this example, consider the table
|
||||
.BR journal ,
|
||||
which appears as follows:
|
||||
.DM
|
||||
Date Amount Account Ref Description
|
||||
------- ------- ------- ------- --------------------------------
|
||||
820107 14.00 meal v meal with jones
|
||||
820113 101.62 car v car repairs
|
||||
820114 81.80 insur c car insurance allstate
|
||||
820114 93.00 car c car registration dmv
|
||||
820119 81.72 vitamin c sundown vitamins
|
||||
820121 20.83 meal v meal with scott
|
||||
820121 2500.00 keogh c keogh payment
|
||||
820125 99.00 dues v dues to uni-ops unix conference
|
||||
.DE
|
||||
.PP
|
||||
And consider the table
|
||||
.BR carexpense ,
|
||||
which appears as follows:
|
||||
.DM
|
||||
Date Amount Account Ref Description
|
||||
------- ------- ------- ------- --------------------------------
|
||||
820113 101.62 car v car repairs
|
||||
820114 81.80 insur c car insurance allstate
|
||||
820114 93.00 car c car registration dmv
|
||||
.DE
|
||||
.PP
|
||||
The command
|
||||
.DM
|
||||
difference journal carexpense
|
||||
.DE
|
||||
.PP
|
||||
logically ``subtracts''
|
||||
.B carexpense
|
||||
from
|
||||
.BR journal ,
|
||||
to produce the following output:
|
||||
.DM
|
||||
Date Amount Account Ref Description
|
||||
------- ------- ------- ------- --------------------------------
|
||||
820107 14.00 meal v meal with jones
|
||||
820119 81.72 vitamin c sundown vitamins
|
||||
820121 20.83 meal v meal with scott
|
||||
820121 2500.00 keogh c keogh payment
|
||||
820125 99.00 dues v dues to uni-ops unix conference
|
||||
.DE
|
||||
.SH "See Also"
|
||||
COHERENT Lexicon:
|
||||
.B
|
||||
diff,
|
||||
diff3,
|
||||
sort,
|
||||
uniq
|
||||
.R
|
||||
.SO difference
|
||||
@@ -0,0 +1,35 @@
|
||||
.TH display "" "" "/rdb Command"
|
||||
.PC "Write table or list file to standard output"
|
||||
\fBdisplay < \fItableorlist\fR
|
||||
.PP
|
||||
.II "file^copy"
|
||||
.II "file^write"
|
||||
.II "copy file"
|
||||
.II "write file"
|
||||
.II "standard input"
|
||||
.II "standard output"
|
||||
The command
|
||||
.B display
|
||||
copies
|
||||
.I tableorlist
|
||||
from the standard input to the standard output.
|
||||
This is not a very useful program, but is a template for the
|
||||
C interface programs.
|
||||
If you have its source code,
|
||||
you have an example of how to process tables and lists
|
||||
and can modify it for your own programs.
|
||||
.PP
|
||||
.II cat
|
||||
.B display
|
||||
is slower than the COHERENT command
|
||||
.B cat
|
||||
because it does more processing.
|
||||
.B display
|
||||
knows about table and list formats, and reads and writes
|
||||
one row at a time.
|
||||
.SH "See Also"
|
||||
COHERENT Lexicon:
|
||||
.B
|
||||
cat,
|
||||
more
|
||||
.R
|
||||
+150
@@ -0,0 +1,150 @@
|
||||
.TH domain "" "" "/rdb Command"
|
||||
.PC "Display invalid values in a column"
|
||||
\fBdomain \fIdomaintable \fB[\fIstring ...\fB] [< \fIone-column-table\fB]\fR
|
||||
.PP
|
||||
.II "table^validate"
|
||||
.II "validate table"
|
||||
.II "domain table"
|
||||
The command
|
||||
.B domain
|
||||
displays all strings or all rows in
|
||||
.I one-column-table
|
||||
that do not match any entry in the
|
||||
.IR domaintable .
|
||||
.PP
|
||||
.B domain
|
||||
is useful for validating that each item in a column
|
||||
is legitimate.
|
||||
First, build a file that consists of a list of all legal values.
|
||||
In relational theory, these values are called the
|
||||
.I domain
|
||||
of the column.
|
||||
(You can also use the command
|
||||
.B validate
|
||||
to validate numbers and short lists of valid strings.)
|
||||
.PP
|
||||
To check the domain of a column in a multicolumn table, simply use the
|
||||
command
|
||||
.B column
|
||||
to project the column you want.
|
||||
.PP
|
||||
The
|
||||
.I domaintable
|
||||
must be sorted because it be searched by the command
|
||||
.B search
|
||||
using the binary fast-access method (\fB\-mb\fR).
|
||||
.B domain
|
||||
is a shell script, so you can edit it to change its search method,
|
||||
.SH Example
|
||||
You might have an order file for cars like this:
|
||||
.DM
|
||||
Qty Model Colors Options
|
||||
------- ------- ------- -------
|
||||
1 sedan black 3
|
||||
1 sedan green 1
|
||||
1 sedan farble 4
|
||||
3 sedan red 5
|
||||
2 convert white 1
|
||||
1 sedan purple 2
|
||||
1 sedan yellow 4
|
||||
3 convert blue 2
|
||||
.DE
|
||||
.PP
|
||||
You would also need a sorted file of possible car colors:
|
||||
.DM
|
||||
Colors
|
||||
------
|
||||
black
|
||||
blue
|
||||
carmel
|
||||
green
|
||||
purple
|
||||
red
|
||||
silver
|
||||
white
|
||||
.DE
|
||||
.PP
|
||||
Now we can validate the
|
||||
.B Color
|
||||
column and see all unacceptable colors:
|
||||
.DM
|
||||
column Colors < orders | domain colors
|
||||
.DE
|
||||
.PP
|
||||
This produces the following output:
|
||||
.DM
|
||||
Colors
|
||||
------
|
||||
farble
|
||||
yellow
|
||||
.DE
|
||||
.PP
|
||||
.B domain
|
||||
complains about
|
||||
.B farble
|
||||
and
|
||||
.B yellow
|
||||
because neither color is in our domain list.
|
||||
.PP
|
||||
You can invoke
|
||||
.B orders
|
||||
in the text editor and edit it,
|
||||
or add those colors to the approved list.
|
||||
In
|
||||
.B vi
|
||||
use the
|
||||
.B /pattern
|
||||
command to find all of the
|
||||
.I patterns
|
||||
in the orders file.
|
||||
Another approach is to type something like this:
|
||||
.DM
|
||||
:g/farble/s//purple/g
|
||||
.DE
|
||||
.PP
|
||||
This
|
||||
.B vi
|
||||
command will find all instances of
|
||||
.B farble
|
||||
and change them to
|
||||
.BR purple .
|
||||
.PP
|
||||
You can also validate strings written on the command line.
|
||||
For example, the command
|
||||
.DM
|
||||
domain colors red blue purple farble yellow green
|
||||
.DE
|
||||
.PP
|
||||
also prints the output:
|
||||
.DM
|
||||
farble
|
||||
yellow
|
||||
.DE
|
||||
.PP
|
||||
These command-line stings should be quoted if they have
|
||||
any special characters in them.
|
||||
They are sought by the command
|
||||
.BR grep .
|
||||
If they contain a dollar sign `$',
|
||||
it should be protected with three backslashes:
|
||||
this expression is scanned both by the shell and by
|
||||
.BR grep ,
|
||||
and it takes three backslashes to get one
|
||||
backslash through to
|
||||
.BR grep .
|
||||
.SH "See Also"
|
||||
.B
|
||||
column,
|
||||
search,
|
||||
validate,
|
||||
ve
|
||||
.R
|
||||
.br
|
||||
COHERENT Lexicon:
|
||||
.B
|
||||
egrep,
|
||||
grep,
|
||||
sort,
|
||||
uniq
|
||||
.R
|
||||
.SO domain
|
||||
+257
@@ -0,0 +1,257 @@
|
||||
.TH enter "" "" "/rdb Command"
|
||||
.PC "Add rows to a table or list file without an editor"
|
||||
\fBenter [\-\fIlimit\fB] \fItableorlist\fR
|
||||
.PP
|
||||
.II "row^append"
|
||||
.II "table^add row"
|
||||
.II "table^append row"
|
||||
.II "append row"
|
||||
.II "add row"
|
||||
The command
|
||||
.B enter
|
||||
is a simple way to append one or more rows to the end of
|
||||
.IR tableorlist .
|
||||
It displays each column name and waits for you to type each item.
|
||||
.PP
|
||||
.B enter
|
||||
is a substitute for the form-editor
|
||||
.BR ve .
|
||||
It is easier to use, but very limited.
|
||||
.PP
|
||||
Note that this is one of the few
|
||||
.B /rdb
|
||||
commands that does not use the less-than symbol `<'
|
||||
to input a table,
|
||||
but requires the name of a table to which it is to append data.
|
||||
.PP
|
||||
If you make an error in entering a record, you can return to the last
|
||||
line by typing a caret `^';
|
||||
.B enter
|
||||
then prompts you with the previous line.
|
||||
If you return two lines, keep typing carets
|
||||
until you are prompted for the line you wish to reenter.
|
||||
.SH Options
|
||||
The option \fB\-\fIlimit\fR
|
||||
lets you limit the number of rows to be entered.
|
||||
For example, \fB\-1\fR prompts for one row and then exits.
|
||||
Thus, it can be used in a shell script.
|
||||
.SH Rules
|
||||
To set up and enter a file in list format instead of table format, there
|
||||
are several rules and suggestions.
|
||||
.PP
|
||||
First, let's discuss terminology.
|
||||
A list is like a table that is turned sideways.
|
||||
For example, a wide table looks like this:
|
||||
.DM
|
||||
Number Name Company Street City State ZIP
|
||||
Phone
|
||||
------ ---- ------- ------ ---- ----- ---
|
||||
-----
|
||||
1 Ronald McDonald McDonald's 123 Mac Attack
|
||||
Memphis TENN 30000 (111) 222-3333
|
||||
.DE
|
||||
.PP
|
||||
Note that the row is so long that it wrapped around to the next line.
|
||||
Also, the column names and column data do not line up.
|
||||
.IR Names ,
|
||||
.IR Companies ,
|
||||
and
|
||||
.I "Street Addresses"
|
||||
are usually too long to fit nicely into such a table.
|
||||
Therefore, we need a list format 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
|
||||
.DE
|
||||
.PP
|
||||
These two formats (table and list) are made interchangeable by using two
|
||||
programs:
|
||||
.B listtotable
|
||||
and
|
||||
.BR tabletolist .
|
||||
You can enter and keep a file in list format.
|
||||
When you want to use several commands,
|
||||
you can convert it to table format and pipe it into the regular
|
||||
commands for faster execution.
|
||||
For example, the command
|
||||
.DM
|
||||
listtotable < maillist | column Name Phone | justify
|
||||
.DE
|
||||
.PP
|
||||
produces the following output:
|
||||
.DM
|
||||
Name Phone
|
||||
--------------- --------------
|
||||
Ronald McDonald (111) 222-3333
|
||||
.DE
|
||||
.PP
|
||||
It is best, therefore, to remember that
|
||||
.B Name
|
||||
and
|
||||
.B Phone
|
||||
are column names.
|
||||
The information that follows them in the list
|
||||
is the first row of a table (that can be created by the command
|
||||
.BR listtotable ).
|
||||
.IP "\fB1.\fR"
|
||||
First use an editor to create the list file.
|
||||
Type each column name followed by one, and only one, tab.
|
||||
Also enter the information for the first row (record).
|
||||
.IP "\fB2.\fR"
|
||||
Be sure to put a newline (blank line)
|
||||
as the first line of the file.
|
||||
.IP "\fB3.\fR"
|
||||
Be sure to put a blank line at the end of each row (record).
|
||||
In the previous example, it should appear after the row
|
||||
.BR Phone .
|
||||
This tells the program that it has reached the end of the row.
|
||||
.sp \n(pDu
|
||||
You can then save the file and use the
|
||||
.B enter
|
||||
program.
|
||||
Type:
|
||||
.DM
|
||||
enter maillist
|
||||
.sp
|
||||
Name _
|
||||
.DE
|
||||
.sp \n(pDu
|
||||
.B enter
|
||||
responds with the first column name and
|
||||
a tab, and waits for you to enter whatever you wish for
|
||||
.BR Name .
|
||||
The underscore `_' shows where the cursor
|
||||
of your terminal will be waiting for you to input data.
|
||||
.IP "\fB4.\fR"
|
||||
Type in your data for the item.
|
||||
Use the return key to end the information for this item.
|
||||
If you type more than 80 characters or so, your terminal will wrap around.
|
||||
You can continue to type and wrap around until
|
||||
you reach your editor's line limit or press \fB<Return>\fR.
|
||||
Then
|
||||
.B enter
|
||||
gives you the name of the next column head,
|
||||
a tab, and waits for your entry.
|
||||
.IP "\fB5.\fR"
|
||||
When
|
||||
.B enter
|
||||
has given you the first
|
||||
column name of a new record and is waiting for a response,
|
||||
exit from it by typing \fB<ctrl-D>\fR.
|
||||
.B enter
|
||||
then returns you to the COHERENT shell.
|
||||
.sp \n(pDu
|
||||
For list-formatted files, it is better to use the
|
||||
.B enter
|
||||
command than an editor.
|
||||
If you do your entry with a text editor,
|
||||
you must include all of the column names,
|
||||
in the same order and spelled correctly.
|
||||
.SH Example
|
||||
To add a line to file
|
||||
.BR maillist ,
|
||||
type the following:
|
||||
.DM
|
||||
enter maillist
|
||||
.DE
|
||||
.PP
|
||||
The editing session may go as follows:
|
||||
.DM
|
||||
Number 2
|
||||
Name Chiquita Banana
|
||||
Company Standard Brands
|
||||
Street ^
|
||||
Company United Brands
|
||||
Street Uno Avenido de la Reforma
|
||||
City San Jose
|
||||
State Costa Rica
|
||||
ZIP 123456789
|
||||
Phone 1234
|
||||
.sp
|
||||
Name \fB<ctrl-D>\fP
|
||||
.DE
|
||||
.PP
|
||||
Note we made an error entering
|
||||
.B Company
|
||||
and did not realize it until we were at
|
||||
.B Street.
|
||||
We typed a caret `^' that reprompted us for
|
||||
.BR Company ,
|
||||
which we then reentered.
|
||||
.B enter
|
||||
then went on to prompt us for
|
||||
.B Company
|
||||
again.
|
||||
.PP
|
||||
The entered file now appears as follows:
|
||||
.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
|
||||
Note that the last row (actually eight lines and the bottom
|
||||
newline) is the one we entered.
|
||||
Just press \fB<Return>\fR if you have no data to enter after a prompt.
|
||||
.PP
|
||||
Now for an example of \fBenter\fRing a table.
|
||||
If you want to add a line to
|
||||
.BR inventory ,
|
||||
type:
|
||||
.DM
|
||||
enter inventory
|
||||
.sp
|
||||
Item# Amount Cost Value Description
|
||||
------- ------- ------- ------- ---------------
|
||||
.DE
|
||||
.PP
|
||||
Then start typing your rows.
|
||||
Remember to insert tabs between columns:
|
||||
.DM
|
||||
8 123 5.98 0 widget
|
||||
9 29 15.50 0 another widget
|
||||
\fB<ctrl-D>\fP
|
||||
.DE
|
||||
.PP
|
||||
The inventory file now looks like this:
|
||||
.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
|
||||
8 123 5.98 0 widget
|
||||
9 29 15.50 0 another widget
|
||||
.DE
|
||||
.PP
|
||||
Note that the last two lines are the ones we entered.
|
||||
.SH "See Also"
|
||||
.B
|
||||
listtotable,
|
||||
tabletolist,
|
||||
ve
|
||||
.R
|
||||
@@ -0,0 +1,76 @@
|
||||
.TH explode "" "" "/rdb Command"
|
||||
.PC "Produce table of subparts and their count for a part"
|
||||
\fBexplode \fIPart Amount \fB[ \fItable \fB]\fR
|
||||
.PP
|
||||
.II "table^explode part"
|
||||
.II "explode part into subparts"
|
||||
The command
|
||||
.B explode
|
||||
takes a part number or name and looks it up in a part table
|
||||
to find all of its subparts.
|
||||
It then finds the subparts of those subparts, and so forth, until
|
||||
it can seek no farther.
|
||||
.B explode
|
||||
also multiplies the number of parts times the subpart
|
||||
counts at each interaction, so the final subpart table
|
||||
lists all of the subparts of the original part and the
|
||||
total number of subparts needed to make the part.
|
||||
.PP
|
||||
You can use
|
||||
.B explode
|
||||
to generate a list of all items needed to make a product.
|
||||
The cost of these subparts, times the count,
|
||||
gives the value that can be totaled to arrive at the total
|
||||
cost of the product.
|
||||
.PP
|
||||
.B explode
|
||||
assumes that the
|
||||
.BR Part ,
|
||||
.BR Subpart ,
|
||||
and
|
||||
.B Count
|
||||
columns
|
||||
are the first three columns of the table, and that the third column
|
||||
is actually named
|
||||
.BR Count .
|
||||
.SH Example
|
||||
If you had a
|
||||
.B parttable,
|
||||
like this:
|
||||
.DM
|
||||
Part Subpart Count
|
||||
---- ------- ------
|
||||
10001 10010 3
|
||||
10001 10020 4
|
||||
10010 10100 2
|
||||
10020 10100 5
|
||||
.DE
|
||||
.PP
|
||||
and you wanted to find the subpart list and count for
|
||||
two part 10001s, you would type:
|
||||
.DM
|
||||
explode 10001 2
|
||||
.DE
|
||||
.PP
|
||||
The result would be:
|
||||
.DM
|
||||
Part Amount
|
||||
---- ------
|
||||
10001 2
|
||||
10010 6
|
||||
10020 8
|
||||
10100 52
|
||||
.DE
|
||||
.PP
|
||||
Note that both 10010 and 10020 have 10100 as a subpart, but
|
||||
.B explode
|
||||
uses
|
||||
.B subtotal
|
||||
to combine the 10100 subparts into one row.
|
||||
The table is also sorted.
|
||||
.SH "See Also"
|
||||
.B
|
||||
bom,
|
||||
subtotal
|
||||
.R
|
||||
.SO explode
|
||||
+129
@@ -0,0 +1,129 @@
|
||||
.TH fd "" "" "/rdb Command"
|
||||
.PC "Test for functional dependency of columns"
|
||||
\fBfd \fIdeterminecolumn dependcolumn \fB< \fItable\fR
|
||||
.PP
|
||||
.II "column^functional dependency"
|
||||
.II "functional dependency^test"
|
||||
.II "test functional dependency"
|
||||
The command
|
||||
.B fd
|
||||
reads
|
||||
.I table
|
||||
and tests whether its
|
||||
.I determinecolumn
|
||||
determines
|
||||
.IR dependcolumn .
|
||||
A column in a table functionally depends upon another column
|
||||
when there is only one value in the second column for each value in
|
||||
the first.
|
||||
This helps you to determine if a table is normalized.
|
||||
(See the section on
|
||||
.BR Normalization ,
|
||||
below, for details on what this means.)
|
||||
.SH Example
|
||||
First let's look at our inventory table:
|
||||
.DM
|
||||
Item Amount Cost Value Description
|
||||
---- ------ ---- ----- --------------
|
||||
1 3 50 150 rubber gloves
|
||||
2 100 5 500 test tubes
|
||||
3 5 80 400 clamps
|
||||
4 23 19 437 plates
|
||||
5 99 24 2376 cleaning cloth
|
||||
6 89 147 13083 bunsen burners
|
||||
7 5 175 875 scales
|
||||
.DE
|
||||
.PP
|
||||
Note that the first column,
|
||||
.B Item,
|
||||
is the key column for the table.
|
||||
It functionally determines all of the other columns.
|
||||
Each value in column
|
||||
.B Item
|
||||
is unique, so each value determines, or is the key,
|
||||
to its row and all of the column values on it.
|
||||
.PP
|
||||
However, column
|
||||
.B Cost
|
||||
does not functionally depend upon
|
||||
.B Amount
|
||||
because there are two `5' values in
|
||||
.B Amount
|
||||
and each has a different value for
|
||||
.B Cost
|
||||
associated with it (on the same row or line).
|
||||
The common sense (technically called the ``semantics'') of the
|
||||
table is that knowing the number of items we have in inventory
|
||||
does not tell us how much they cost.
|
||||
.PP
|
||||
Now let's see if
|
||||
.B fd
|
||||
can find the dependencies.
|
||||
The command
|
||||
.DM
|
||||
fd Item Cost < inventory
|
||||
.DE
|
||||
.PP
|
||||
returns the message
|
||||
.BR true .
|
||||
This is correct, because
|
||||
.B Item
|
||||
is the key column.
|
||||
However, the command
|
||||
.DM
|
||||
fd Amount Cost < inventory
|
||||
.DE
|
||||
.PP
|
||||
returns the message
|
||||
.BR false .
|
||||
This, too, is correct.
|
||||
.SH Normalization
|
||||
A key column should aways functionally determine all
|
||||
of the other columns in the table.
|
||||
But nonkey columns should not depend upon each other.
|
||||
.PP
|
||||
If there are too few data in the table, a
|
||||
pseudo-dependency may be discovered.
|
||||
Be sure your table has lots of data before you test it.
|
||||
.PP
|
||||
To normalize your tables, you must check for functional
|
||||
dependencies.
|
||||
When functional dependency is found with non\-key columns,
|
||||
the columns should be projected and uniqued to form a second table.
|
||||
Then the functionally dependent column, but not the
|
||||
determining column, should be removed from the first table.
|
||||
For example:
|
||||
.DM
|
||||
column column1 column2 < table | uniq > newtable
|
||||
column `sed 1q table | sed s/column2//` < table > tmp
|
||||
mv tmp table
|
||||
.DE
|
||||
.PP
|
||||
In the second table, the column that determines the other column
|
||||
is the key for that table.
|
||||
If you need to recreate the original first table, you can
|
||||
join the two new tables by using the command
|
||||
.BR jointable ,
|
||||
as follows:
|
||||
.DM
|
||||
jointable -j column1 table newtable > oldtable
|
||||
.DE
|
||||
.PP
|
||||
Normalization, or simplification, is an important process.
|
||||
Normalized files are smaller and are easier to maintain.
|
||||
.SH "See Also"
|
||||
.B
|
||||
column,
|
||||
jointable,
|
||||
paste.rdb
|
||||
.R
|
||||
.br
|
||||
COHERENT Lexicon:
|
||||
.B
|
||||
cut,
|
||||
false,
|
||||
mv,
|
||||
paste,
|
||||
sed,
|
||||
true
|
||||
.SO fd
|
||||
@@ -0,0 +1,64 @@
|
||||
.TH filesize "" "" "/rdb Command"
|
||||
.PC "Return the number of characters in a file"
|
||||
\fBfilesize \fIfile ...\fR
|
||||
.PP
|
||||
.II "table^size"
|
||||
.II "size of table"
|
||||
.II file^size
|
||||
The command
|
||||
.B filesize
|
||||
displays the number of bytes in each
|
||||
.IR file .
|
||||
.II wc
|
||||
.II stat()
|
||||
It is much faster than the COHERENT command
|
||||
.B wc
|
||||
because it uses the system call
|
||||
.B stat()
|
||||
to get the number from the i-node table,
|
||||
rather than counting the bytes in the file.
|
||||
.PP
|
||||
If you ask
|
||||
.B filesize
|
||||
to size only one file,
|
||||
it sends one number to the
|
||||
standard output.
|
||||
This number can be assigned to a shell variable.
|
||||
With more than one
|
||||
.IR file ,
|
||||
it produces a table of sizes.
|
||||
.SH Example
|
||||
The following command returns the size of file
|
||||
.BR filesize.1 ,
|
||||
which holds the ``raw'' form of what you are reading:
|
||||
.DM
|
||||
filesize filesize.1
|
||||
.DE
|
||||
.PP
|
||||
This displays one value on the standard output, e.g.:
|
||||
.DM
|
||||
532
|
||||
.DE
|
||||
.PP
|
||||
The following command asks for the size of files
|
||||
.B ascii.1
|
||||
and
|
||||
.BR filesize.1 :
|
||||
.DM
|
||||
filesize ascii.1 filesize.1
|
||||
.DE
|
||||
.PP
|
||||
This form of the command returns a tabular output, e.g.:
|
||||
.DM
|
||||
Offset Filename
|
||||
-------- --------
|
||||
464 ascii.1
|
||||
532 filesize.1
|
||||
.DE
|
||||
.SH "See Also"
|
||||
COHERENT Lexicon:
|
||||
.B
|
||||
ls,
|
||||
stat(),
|
||||
wc
|
||||
.R
|
||||
@@ -0,0 +1,62 @@
|
||||
.TH fillform "" "" "/act/gl Command"
|
||||
.PC "Fill a tax from with adjusted trial balance data"
|
||||
\fBfillform \fIform\fR
|
||||
.PP
|
||||
.II "tax form^fill"
|
||||
.II "fill tax form"
|
||||
The command
|
||||
.B fillform
|
||||
is part of the accounting/general-ledger system included with
|
||||
.BR /rdb .
|
||||
It fills in the tax form
|
||||
.IR form ,
|
||||
which must be one of
|
||||
.B 1120
|
||||
(corporate),
|
||||
.B 1120S
|
||||
(S corporation),
|
||||
.B C
|
||||
(schedule C), or partnership tax form.
|
||||
It writes its output into a file with the name
|
||||
.IR form .
|
||||
.SH Example
|
||||
The following example fills in the S corporation form:
|
||||
.DM
|
||||
fillform 1120S
|
||||
.DE
|
||||
.PP
|
||||
When you post-process the output with the command
|
||||
.DM
|
||||
sed 10q 1120S
|
||||
.DE
|
||||
.PP
|
||||
you see output that resembles the following:
|
||||
.DM
|
||||
Taxline Amount Description
|
||||
------- ------ --------------------------------------
|
||||
101a 13500 Sales
|
||||
101b 0 Returns and Allowances
|
||||
101c 13500 Net Sales
|
||||
102 0 Cost of Goods Sold
|
||||
102-A1 20000 Beginning Inventory
|
||||
102-A2 3601 Misc Merchandise
|
||||
102-A3 2100 Salaries and Wages
|
||||
102-A4 0 Other Costs
|
||||
.DE
|
||||
.SH "See Also"
|
||||
.B
|
||||
calculate
|
||||
.R
|
||||
.br
|
||||
COHERENT Lexicon:
|
||||
.B
|
||||
sed
|
||||
.R
|
||||
.SO fillform
|
||||
.SH Notes
|
||||
Please note the tax tables and forms included with
|
||||
.B /rdb
|
||||
are from 1987.
|
||||
These are examples, and no claim is made for their accuracy in computing
|
||||
this year's taxes.
|
||||
.IR "Caveat utilitor" .
|
||||
@@ -0,0 +1,68 @@
|
||||
.TH fixtotable "" "" "/rdb Command"
|
||||
.PC "Converts fixed length format to /rdb table format"
|
||||
\fBfixtotable \fIcolumn\fB\|[=\|\fIn1\fB,\fIn2\fB] ... < \fIfixtdb\fR
|
||||
.PP
|
||||
.II "table^convert format"
|
||||
.II "table^fixed length"
|
||||
.II "convert table format"
|
||||
The command
|
||||
.B fixtotable
|
||||
converts a data base from fixed-length format to
|
||||
variable length \fB/rdb\fR format.
|
||||
It does so
|
||||
by selecting \fIn2\fR bytes of data from table \fIfixtdb\fR,
|
||||
beginning at the \fIn1\fR position for each \fIcolumn\fR specified.
|
||||
It inserts tabs between columns and calls the
|
||||
.B /rdb
|
||||
command
|
||||
.B compress
|
||||
to remove leading and trailing blanks.
|
||||
It generates
|
||||
header records from the column names.
|
||||
Column names that do not specify start position (\fIn1\fR) and
|
||||
field width (\fIn2\fR) are considered empty columns, and appear
|
||||
as such in the output.
|
||||
Blank records are removed.
|
||||
.SH Example
|
||||
For example, let's look at a file named \fBjournal\fR:
|
||||
.DM
|
||||
1 10 20 30
|
||||
----+----|----+----|----+----|
|
||||
820102101 25000
|
||||
820102211.1 25000
|
||||
820103150.1 10000
|
||||
820103101 5000
|
||||
820103211.2 5000
|
||||
820104130 30000
|
||||
.DE
|
||||
.PP
|
||||
The first six bytes are the date field;
|
||||
the next six bytes, starting at position 7 are the account number field;
|
||||
the next seven bytes, starting at position 13 are the credit field;
|
||||
and the last seven bytes, starting at position 20 are the debit field.
|
||||
.PP
|
||||
The following command yanks
|
||||
the account number and the credit and debit fields from
|
||||
.BR journal ,
|
||||
makes a new table with a new field for the description:
|
||||
.DM
|
||||
fixtotable Account=7,6 Debit=13,7 Credit=20,7 Description < journal
|
||||
.DE
|
||||
.PP
|
||||
This produces the following table:
|
||||
.DM
|
||||
Account Debit Credit Description
|
||||
------- ----- ------ -----------
|
||||
101 25000
|
||||
211.1 25000
|
||||
150.1 10000
|
||||
101 5000
|
||||
211.2 5000
|
||||
130 30000
|
||||
.DE
|
||||
.SH "See Also"
|
||||
.B
|
||||
compress,
|
||||
tabletofix
|
||||
.R
|
||||
.SO fixtotable
|
||||
@@ -0,0 +1,63 @@
|
||||
.TH foot "" "" "/act/gl Command"
|
||||
.PC "Foot or subtotal Debits and Credit of ledger"
|
||||
.B foot
|
||||
.PP
|
||||
.II "account^subtotal"
|
||||
.II "table^subtotal"
|
||||
.II "subtotal table"
|
||||
The command
|
||||
.B foot
|
||||
is part of the accounting/general-ledger system included with
|
||||
.BR /rdb .
|
||||
It subtotals the accounts in table
|
||||
.BR ledger .
|
||||
.SH Example
|
||||
The command
|
||||
.B foot
|
||||
produces a table that resembles the following:
|
||||
.DM
|
||||
Account Date Debit Credit Ref Short Description
|
||||
------- ------ ----- ------ ------- ------- ------------------
|
||||
1010 851231 1758 cash
|
||||
1010 851231 5137 cash
|
||||
------- ------ ----- ------ ------- ------- ------------------
|
||||
1010 5137 1758
|
||||
.DE
|
||||
.DM
|
||||
3010 1601 deposit sales
|
||||
------- ------ ----- ------ ------- ------- ------------------
|
||||
3010 0 1601
|
||||
.DE
|
||||
.DM
|
||||
3080 850125 250 c1459 royalty book fees
|
||||
------- ------ ----- ------ ------- ------- ------------------
|
||||
3080 0 250
|
||||
.DE
|
||||
.DM
|
||||
3100 850118 3286 c101 income sales
|
||||
------- ------ ----- ------ ------- ------- ------------------
|
||||
3100 0 3286
|
||||
.DE
|
||||
.DM
|
||||
4020 1601 check merch
|
||||
------- ------ ----- ------ ------- ------- ------------------
|
||||
4020 1601 0
|
||||
.DE
|
||||
.DM
|
||||
4370 850101 2 r parking parking at clients
|
||||
------- ------ ----- ------ ------- ------- ------------------
|
||||
4370 2 0
|
||||
.DE
|
||||
.DM
|
||||
4380 850103 15 c115 travel shuttle bus
|
||||
4380 850104 13 v travel meal
|
||||
4380 850105 13 c116 travel meal
|
||||
4380 850106 114 r travel hotel
|
||||
------- ------ ----- ------ ------- ------- ------------------
|
||||
4380 155 0
|
||||
.DE
|
||||
.SH "See Also"
|
||||
.B
|
||||
act
|
||||
.R
|
||||
.SO foot
|
||||
@@ -0,0 +1,35 @@
|
||||
.TH getjournal "" "" "/act/gl Command"
|
||||
.PC "Copy journals for sales, purchasing, pay systems"
|
||||
\fBgetjournal \fIjournalname\fR
|
||||
.PP
|
||||
.II "journal^manipulate"
|
||||
.II "manipulate journals"
|
||||
The command
|
||||
.B getjournal
|
||||
is part of the accounting/general-ledger system included with
|
||||
.BR /rdb .
|
||||
It copies, totals, and adjusts journals from other parts of the
|
||||
business system.
|
||||
These subsidiary journals are created automatically by the
|
||||
operations of sales, purchasing, and other departments.
|
||||
It also gets the inventory value for the table
|
||||
.BR journaladjust .
|
||||
.SH Example
|
||||
The command
|
||||
.DM
|
||||
getjournal journaldeposit
|
||||
.DE
|
||||
.PP
|
||||
reads the table
|
||||
.B journaldeposit
|
||||
and prints on the standard output a table that resembles the following:
|
||||
.DM
|
||||
Date Amount Account Ref Description
|
||||
------- ------- ------- ------- --------------------------
|
||||
891231 13500.00 sales deposit from sales/deposit
|
||||
.DE
|
||||
.SH "See Also"
|
||||
.B
|
||||
act,
|
||||
consolidate
|
||||
.R
|
||||
@@ -0,0 +1,171 @@
|
||||
.TH gregorian "" "" "/rdb Command"
|
||||
.PC "Convert column of dates for arithmetic and format change"
|
||||
\fBgregorian [ \-ceu ] [ \fIColumn ... \fB] < \fItableorlist\fR
|
||||
.PP
|
||||
.II "date^Gregorian"
|
||||
.II "Gregorian date"
|
||||
.II "date^convert"
|
||||
The command
|
||||
.B gregorian
|
||||
converts Julian dates in one or more
|
||||
.BR Column s
|
||||
to Gregorian date.
|
||||
When used with the command
|
||||
.BR julian ,
|
||||
you can do the following:
|
||||
.IP \fB1.\fR 0.3i
|
||||
Add days to a date.
|
||||
.IP \fB2.\fR
|
||||
Subtract days from a date.
|
||||
.IP \fB3.\fR
|
||||
Subtract two dates to find the number of days between them.
|
||||
.IP \fB4.\fR
|
||||
Change the format of a date.
|
||||
.PP
|
||||
A Gregorian date is a string that presents the date of the
|
||||
current year, month, and day; for example ``911231''.
|
||||
A Julian date, however, is the number of days since the
|
||||
beginning of the Julian calendar (January 1, 4713 BC).
|
||||
This system is used by astronomers, computer programmers, and other
|
||||
people who wish to store dates in a form that can be
|
||||
easily translated from one system of dating to another, without having
|
||||
to worry about leap years, dates of the births of religious figures, etc.
|
||||
Because Julian dates are integers,
|
||||
you can subtract one from another to find the number of days between
|
||||
two dates.
|
||||
.PP
|
||||
To perform arithmetic on dates, first use the command
|
||||
.B julian
|
||||
to convert the dates from Gregorian form to Julian.
|
||||
Then, use the command
|
||||
.B compute
|
||||
to add or subtract the dates (or add a constant to a date).
|
||||
Finally, use
|
||||
.B gregorian
|
||||
to convert the sum or the difference back to Gregorian form.
|
||||
.SH Options
|
||||
.B gregorian
|
||||
recognizes the following options:
|
||||
.IP \fB\-c\fR 0.3i
|
||||
Output
|
||||
\fIcomputer\fR
|
||||
date format, i.e., \fIYYMMDD\fR.
|
||||
.B /rdb
|
||||
uses this format by default for its Gregorian dates
|
||||
because it can be sorted and selected in correct numerical sequence.
|
||||
.IP \fB\-e\fR
|
||||
Output
|
||||
.I European
|
||||
date format, i.e., \fIDD/MM/YY\fR.
|
||||
.IP \fB\-u\fR
|
||||
Output
|
||||
.I U.S.
|
||||
date format, i.e., \fIMM/DD/YY\fR.
|
||||
.SH Example
|
||||
The first example shows how to add dates.
|
||||
Suppose we have a file called
|
||||
.BR journal ,
|
||||
as follows:
|
||||
.DM
|
||||
Date Account Debit Credit Description
|
||||
------ ------- ----- ------ ----------------------------------
|
||||
861222 101 25000 cash from loan
|
||||
861222 211.1 25000 loan number #378-14 Bank Amerigold
|
||||
861223 150.1 10000 test equipment from Zarkoff
|
||||
861223 101 5000 cash payment
|
||||
861223 211.2 5000 note payable to Zarkoff Equipment
|
||||
861224 130 30000 inventory - parts from CCPSC
|
||||
861224 201.1 15000 accounts payable to CCPSC
|
||||
861224 101 15000 cash payment to CCPSC for parts
|
||||
.DE
|
||||
.PP
|
||||
Now, suppose that we want to add 45 days to each of the dates.
|
||||
First, see what
|
||||
.B julian
|
||||
does.
|
||||
Typing
|
||||
.DM
|
||||
julian Date < journal
|
||||
.DE
|
||||
.PP
|
||||
prints the following on the standard output:
|
||||
.DM
|
||||
Date Account Debit Credit Description
|
||||
------ ------- ----- ------ ----------------------------------
|
||||
1752827 101 25000 cash from loan
|
||||
1752827 211.1 25000 loan number #378-14 Bank Amerigold
|
||||
1752828 150.1 10000 test equipment from Zarkoff
|
||||
1752828 101 5000 cash payment
|
||||
1752828 211.2 5000 note payable to Zarkoff Equipment
|
||||
1752829 130 30000 inventory - parts from CCPSC
|
||||
1752829 201.1 15000 accounts payable to CCPSC
|
||||
1752829 101 15000 cash payment to CCPSC for parts
|
||||
.DE
|
||||
.PP
|
||||
The
|
||||
.B Date
|
||||
column now holds a Julian date.
|
||||
Note we gave no option because computer format is the default.
|
||||
.PP
|
||||
The next command adds 45 days to each entry in the
|
||||
.B Date
|
||||
column:
|
||||
.DM
|
||||
julian Date < journal | compute 'Date += 45' | gregorian Date
|
||||
.DE
|
||||
.PP
|
||||
This command prints the following on the standard output:
|
||||
.DM
|
||||
Date Account Debit Credit Description
|
||||
------ ------- ----- ------ ----------------------------------
|
||||
870205 101 25000 cash from loan
|
||||
870205 211.1 25000 loan number #378-14 Bank Amerigold
|
||||
870206 150.1 10000 test equipment from Zarkoff
|
||||
870206 101 5000 cash payment
|
||||
870206 211.2 5000 note payable to Zarkoff Equipment
|
||||
870207 130 30000 inventory - parts from CCPSC
|
||||
870207 201.1 15000 accounts payable to CCPSC
|
||||
870207 101 15000 cash payment to CCPSC for parts
|
||||
.DE
|
||||
.PP
|
||||
As you can see, every date is now 45 days later than they originally were.
|
||||
.PP
|
||||
The next example converts one format of Gregorian date to another.
|
||||
To convert the
|
||||
.B Date
|
||||
column in our example table from computer format to U.S. format,
|
||||
type the following:
|
||||
.DM
|
||||
julian Date < journal | gregorian -u Date | justify Date
|
||||
.DE
|
||||
.PP
|
||||
The result is as follows:
|
||||
.DM
|
||||
Date Account Debit Credit Description
|
||||
-------- ------- ----- ------ ----------------------------------
|
||||
12/22/86 101 25000 cash from loan
|
||||
12/22/86 211.1 25000 loan number #378-14 Bank Amerigold
|
||||
12/23/86 150.1 10000 test equipment from Zarkoff
|
||||
12/23/86 101 5000 cash payment
|
||||
12/23/86 211.2 5000 note payable`to Zarkoff Equipment
|
||||
12/24/86 130 30000 inventory - parts from CCPSC
|
||||
12/24/86 201.1 15000 accounts payable to CCPSC
|
||||
12/24/86 101 15000 cash payment to CCPSC for parts
|
||||
.DE
|
||||
.PP
|
||||
Because the U.S. format is two characters wider than the
|
||||
computer format, we included the command
|
||||
.B justify
|
||||
in our command line to line things up.
|
||||
.SH "See Also"
|
||||
.B
|
||||
compute,
|
||||
computedate,
|
||||
julian
|
||||
.R
|
||||
.br
|
||||
COHERENT Lexicon:
|
||||
.B
|
||||
awk,
|
||||
date
|
||||
.R
|
||||
@@ -0,0 +1,44 @@
|
||||
.TH hashkey "" "" "/rdb Command"
|
||||
.PC "Return the hash offset for key strings"
|
||||
\fBhashkey \fIrows keystring ...\fR
|
||||
.PP
|
||||
.II "indexing^hash key"
|
||||
.II "hash-key indexing"
|
||||
The command
|
||||
.B hashkey
|
||||
adds the ASCII value of each character in the
|
||||
.IR keystring s
|
||||
(except spaces or tabs), and returns the modulo of
|
||||
.IR rows .
|
||||
This is for computing the hash offset into hash-index table for
|
||||
the hash fast-access method.
|
||||
It is used by the command
|
||||
.B append
|
||||
to update the hash-index table.
|
||||
.SH Example
|
||||
Here we convert several characters.
|
||||
The command
|
||||
.DM
|
||||
hashkey 11 ABCD
|
||||
.DE
|
||||
.PP
|
||||
returns \fB2\fR.
|
||||
(That is, ASCII values 65 plus 66 plus 67 plus 68 yields 266; which, when
|
||||
divided by 11 yields a remainder of 2).
|
||||
The command
|
||||
.DM
|
||||
hashkey 29 abcdefg
|
||||
.DE
|
||||
.PP
|
||||
returns \fB4\fR.
|
||||
.SH "See Also"
|
||||
.B
|
||||
append
|
||||
ascii,
|
||||
chr
|
||||
.R
|
||||
.br
|
||||
COHERENT Lexicon:
|
||||
.B
|
||||
ASCII
|
||||
.R
|
||||
@@ -0,0 +1,37 @@
|
||||
.TH "head line" "" "" "/rdb Definition"
|
||||
.PC
|
||||
.II "/rdb header"
|
||||
.PP
|
||||
The
|
||||
.I "head line"
|
||||
is the first line in an
|
||||
.B /rdb
|
||||
table.
|
||||
It names each column in the table.
|
||||
Each entry in the head line must be separated by a tab character.
|
||||
.SH Example
|
||||
The table
|
||||
.B inventory
|
||||
appears as follows:
|
||||
.DM
|
||||
Item Amount Cost Value Description New
|
||||
---- ------ ---- ----- -------------- -------
|
||||
1 3 50 150 rubber gloves
|
||||
2 100 5 500 test tubes
|
||||
3 5 80 400 clamps
|
||||
4 23 19 437 plates
|
||||
5 99 24 2376 cleaning cloth
|
||||
6 89 147 13083 bunsen burners
|
||||
7 5 175 875 scales
|
||||
.DE
|
||||
.PP
|
||||
The first line
|
||||
.DM
|
||||
Item Amount Cost Value Description New
|
||||
.DE
|
||||
.PP
|
||||
is this table's head line.
|
||||
.SH "See Also"
|
||||
.B
|
||||
dash line, listtotable, tabletolist
|
||||
.R
|
||||
@@ -0,0 +1,58 @@
|
||||
.TH headoff "" "" "/rdb Command"
|
||||
.PC "Remove an /rdb head from both table and list files"
|
||||
\fBheadoff < \fItableorlist\fR
|
||||
.PP
|
||||
.II table^behead
|
||||
.II "behead table"
|
||||
.II "remove header"
|
||||
.II "head line^remove"
|
||||
.II "dash line^remove"
|
||||
The command
|
||||
.B headoff
|
||||
``beheads''
|
||||
.IR tableorlist ;
|
||||
that is, it strips off its header.
|
||||
Tables have two-line column heads; list files have only
|
||||
one line that consists of a single newline character.
|
||||
The COHERENT command
|
||||
.B "tail +3"
|
||||
does the same thing for a table; and
|
||||
.B "tail +2"
|
||||
for a list.
|
||||
.PP
|
||||
The command
|
||||
.B union
|
||||
uses
|
||||
.B headoff
|
||||
to assemble files.
|
||||
Only the first file keeps its head.
|
||||
.SH Example
|
||||
To behead the table
|
||||
.BR inventory ,
|
||||
type:
|
||||
.DM
|
||||
headoff < inventory
|
||||
.DE
|
||||
.PP
|
||||
This writes something like the following on the standard output:
|
||||
.DM
|
||||
1 3 50 150 rubber gloves
|
||||
2 100 5 500 test tubes
|
||||
3 5 80 400 clamps
|
||||
4 23 19 437 plates
|
||||
5 99 24 2376 cleaning cloth
|
||||
6 89 147 13083 bunsen burners
|
||||
7 5 175 875 scales
|
||||
.DE
|
||||
.SH "See Also"
|
||||
.B
|
||||
headon,
|
||||
insertdash,
|
||||
union
|
||||
.R
|
||||
.br
|
||||
COHERENT Lexicon:
|
||||
.B
|
||||
head,
|
||||
tail
|
||||
.R
|
||||
@@ -0,0 +1,69 @@
|
||||
.TH headon "" "" "/rdb Command"
|
||||
.PC "Add an /rdb header to a table"
|
||||
\fBheadon < \fItable\fR
|
||||
.PP
|
||||
.II "table^add head"
|
||||
.II "add head to table"
|
||||
The command
|
||||
.B headon
|
||||
appends an
|
||||
.B /rdb
|
||||
header onto
|
||||
.IR table .
|
||||
Tables have a two-line column head.
|
||||
When you have a table without an
|
||||
.B /rdb
|
||||
header, perhaps created by another program, you can add a head to it.
|
||||
You can also do this in a pipe and send the new table to other
|
||||
.B /rdb
|
||||
commands for processing.
|
||||
.SH Example
|
||||
If you want to treat the file
|
||||
.B /etc/passwd
|
||||
as a table for
|
||||
.B /rdb
|
||||
command processing, use
|
||||
.BR headon ,
|
||||
as follows:
|
||||
.DM
|
||||
tr ':' ' ' < /etc/passwd | headon | justify
|
||||
.DE
|
||||
.PP
|
||||
Note the use of the COHERENT command
|
||||
.B tr
|
||||
to translate a colon `:' into a tab character;
|
||||
and the use of the
|
||||
.B /rdb
|
||||
command
|
||||
.B justify
|
||||
to align the columns.
|
||||
This produces something like the following:
|
||||
.DM
|
||||
1 2 3 4 5 6
|
||||
------ ------------- --- --- --------------- -------------
|
||||
root dVAYxSsJy10Fg 0 3 Super User /
|
||||
daemon 1 12 background /
|
||||
bin rVOhF49RpZXEY 2 2 binary programs /bin
|
||||
uucp 5 1 UUCP /usr/lib/uucp
|
||||
lp 71 2 Line Printer /usr/spool/lp
|
||||
guest 100 100 Guest User /usr/guest
|
||||
rod 0 0 Rod Manis /usr/rod
|
||||
.DE
|
||||
.PP
|
||||
Be sure the first line of the table has no blank fields or
|
||||
.B headon
|
||||
counts the wrong number of fields.
|
||||
.SH "See Also"
|
||||
.B
|
||||
headoff,
|
||||
insertdash,
|
||||
justify,
|
||||
rmblank
|
||||
.R
|
||||
.br
|
||||
COHERENT Lexicon:
|
||||
.B
|
||||
passwd,
|
||||
tr
|
||||
.R
|
||||
.SO headon
|
||||
@@ -0,0 +1,23 @@
|
||||
.TH helpme "" "" "/rdb Command"
|
||||
.PC "List the help commands available"
|
||||
.B helpme
|
||||
.PP
|
||||
The command
|
||||
.B helpme
|
||||
lists all other
|
||||
.B /rdb
|
||||
help commands.
|
||||
.SH Example
|
||||
Typing
|
||||
.B helpme
|
||||
prints the following on the standard output:
|
||||
.DM
|
||||
Command Description
|
||||
------------------ ------------------------------------------
|
||||
"menu" a menu with some commands
|
||||
"rdb" a list of the available commands
|
||||
"commands" description and syntax of all the commands
|
||||
"whatis command" description and syntax of command
|
||||
"whatwill feature" info on commands with that feature
|
||||
"man command" the manual page for that command
|
||||
.DE
|
||||
@@ -0,0 +1,17 @@
|
||||
.TH howmany "" "" "/rdb Command"
|
||||
.PC "Display the number of commands in a directory"
|
||||
.B howmany
|
||||
.PP
|
||||
.II "command^list"
|
||||
.II "list commands"
|
||||
The command
|
||||
.B howmany
|
||||
displays the number of the commands it finds in directory
|
||||
.BR $RDB/bin .
|
||||
.SH "See Also"
|
||||
.B
|
||||
rdb,
|
||||
whatis,
|
||||
whatwill
|
||||
.R
|
||||
.SO howmany
|
||||
+202
@@ -0,0 +1,202 @@
|
||||
.TH index "" "" "/rdb Command"
|
||||
.PC "Set up table for search"
|
||||
\fBindex [\-m[bhirs]] [\-x] [-hsl [2> \fIlocation\fB]] \fItableorlist \fB[\fIkeycol ...\fB] [ < \fIkeytable\fB ]\fR
|
||||
.PP
|
||||
.II "table^index"
|
||||
The command
|
||||
.B index
|
||||
sets up a table for the program
|
||||
.BR search .
|
||||
The indexing it performs increases the speed with which
|
||||
.B search
|
||||
can find a row in a table or list file.
|
||||
This is very important for large files.
|
||||
.PP
|
||||
Exactly what
|
||||
.B index
|
||||
does depends upon the method of indexing you choose.
|
||||
For some methods, it builds another table, called a
|
||||
.IR "secondary index file" ,
|
||||
that the specified method requires.
|
||||
It is possible to index
|
||||
one file by all five methods.
|
||||
Some methods can index all of a table's columns.
|
||||
.PP
|
||||
Please note that these fast-access methods are static.
|
||||
If the table or list
|
||||
is changed \(em by a text editor, for example \(em it may have to
|
||||
be reindexed.
|
||||
Applications should manipulate the table
|
||||
or list files and their secondary index to update them together.
|
||||
Forms packages should dynamically maintain these files.
|
||||
.PP
|
||||
There is a trick to allow you to index any or all of the columns in a file.
|
||||
.II ln
|
||||
Simply use the COHERENT command
|
||||
.B ln
|
||||
to link the file to as many different names as you have columns to index.
|
||||
Then index the table through each of its link aliases.
|
||||
For details, see the COHERENT Lexicon's entry for
|
||||
.BR ln .
|
||||
.SH Options
|
||||
The following options control the method of indexing that
|
||||
.B index
|
||||
produces:
|
||||
.IP \fB\-m\fR
|
||||
Index using the default method, which is sequential.
|
||||
See
|
||||
.BR \-ms ,
|
||||
below.
|
||||
.IP \fB\-mb\fR
|
||||
.II "index^binary"
|
||||
Binary indexing.
|
||||
.B index
|
||||
simply sorts the file on the specified key column.
|
||||
No secondary file is created.
|
||||
Because a file can only be sorted on one column,
|
||||
only one column can be indexed using this method.
|
||||
The command
|
||||
.B sorttable
|
||||
gives the same result as this option.
|
||||
.IP \fB\-mh\fR
|
||||
.II "index^hash table"
|
||||
Hash indexing.
|
||||
.B index
|
||||
builds a secondary-index file, named
|
||||
\fBtableorlist\fB.h\fR,
|
||||
hashes all of the key-column's values,
|
||||
and writes them and their offsets to the secondary-index file.
|
||||
Please note that because the COHERENT system places a limit of 14
|
||||
characters on a file name, the name of
|
||||
.I tableorlist
|
||||
must not exceed 12 characters, or
|
||||
.B index
|
||||
will not be able to name correctly the secondary-index file.
|
||||
.IP \fB\-mi\fR
|
||||
.II "index^inverted"
|
||||
Inverted or indexed indexing.
|
||||
.B index
|
||||
builds a secondary-index file of keys and offsets, then sorts on the keys.
|
||||
The secondary file is named
|
||||
\fItableorlist\fB.i\fR.
|
||||
The trick to index more than one column, previously discussed,
|
||||
alsos work for the inverted method.
|
||||
.sp \n(pDu
|
||||
If you plan on using the incomplete-match feature of
|
||||
search (which works only with the inverted method), you
|
||||
must specify the \fB-x\fR flag, so the secondary index is sorted properly.
|
||||
.IP \fB\-mr\fR
|
||||
.II "index^record number"
|
||||
Record-number indexing.
|
||||
.B index
|
||||
builds a secondary file named
|
||||
\fItableorlist\fB.r\fR,
|
||||
which is one fixed-length column of row offsets.
|
||||
.IP \fB\-ms\fR
|
||||
.II "index^sequential"
|
||||
.II "index^linear"
|
||||
Sequential or linear indexing.
|
||||
.B index
|
||||
does nothing in this case, because
|
||||
.B search
|
||||
simply looks through the whole file.
|
||||
.PP
|
||||
The following options control details of
|
||||
.BR index 's
|
||||
output:
|
||||
.IP \fB\-h\fR
|
||||
No head line on the output table.
|
||||
.IP \fB\-l\fR
|
||||
Write to the standard error the starting and stopping location of each row,
|
||||
and the offset entry in the secondary-index file.
|
||||
.II replace
|
||||
.II lock
|
||||
.II unlock
|
||||
These numbers are used by the commands
|
||||
.BR replace ,
|
||||
.BR lock ,
|
||||
and
|
||||
.BR unlock .
|
||||
.II seek
|
||||
The command
|
||||
.B seek
|
||||
uses this option to find the locations of rows.
|
||||
The locations are sent to standard-error device, which under the
|
||||
Bourne and Korn shells is file descriptor 2;
|
||||
thus, you can redirect them into a file by using the shell operator \fB2>\fR.
|
||||
You can store these data until they are needed by your shell programs.
|
||||
.sp \n(pDu
|
||||
This option produces four integers.
|
||||
If there is no secondary-index file, the start location is zero.
|
||||
.IP \fB\-s\fR
|
||||
Only one row is found.
|
||||
This speeds up some of the methods
|
||||
because they do not have to continue searching
|
||||
after they find the first match.
|
||||
The sequential method will, on average, run twice as fast;
|
||||
whereas the hash, binary, and inverted methods will run slightly faster.
|
||||
The record-access method will not change, as it only finds one match anyway.
|
||||
.SH "Methods and Suffixes"
|
||||
The following gives suffixes that
|
||||
.B index
|
||||
appends to names of tables, in order to name its secondary-index files.
|
||||
.DS
|
||||
.ta 1.25iC 2.5iC
|
||||
\fIMethod Suffix Example\fR
|
||||
\fB\-b\fR None ...
|
||||
\fB\-h\fR .h inventory.h
|
||||
\fB\-i\fR .i inventory.i
|
||||
\fB\-r\fR .r inventory.r
|
||||
\fB\-s\fR None ...
|
||||
.DE
|
||||
.SH Example
|
||||
Let's look at the first ten lines of an accounts chart, named
|
||||
.BR chart :
|
||||
.DM
|
||||
Account Name
|
||||
------- ----------------------
|
||||
100 Assets
|
||||
101 Cash
|
||||
111 Accounts Receivable
|
||||
111.1 Allowance for Bad Debt
|
||||
115 Notes Receivable
|
||||
120 Deposits
|
||||
130 Parts Inventory
|
||||
150 Equipment
|
||||
.DE
|
||||
.PP
|
||||
Access to the data in
|
||||
.B chart
|
||||
can be sped up by indexing it and using the command
|
||||
.B search
|
||||
to find the row you want.
|
||||
To index
|
||||
.B chart
|
||||
using the binary (sorted) search method, type:
|
||||
.DM
|
||||
index -mb chart Account
|
||||
.DE
|
||||
.PP
|
||||
.B index
|
||||
quietly returns when it finishes.
|
||||
You are now ready to use
|
||||
.B search
|
||||
to find an
|
||||
.B Account
|
||||
number in the
|
||||
.B chart .
|
||||
.SH "See Also"
|
||||
.B
|
||||
append,
|
||||
delete,
|
||||
lock,
|
||||
replace,
|
||||
search,
|
||||
unlock,
|
||||
update
|
||||
.R
|
||||
.br
|
||||
COHERENT Lexicon:
|
||||
.B
|
||||
ln
|
||||
.R
|
||||
@@ -0,0 +1,51 @@
|
||||
.TH insertdash "" "" "/rdb Command"
|
||||
.PC "Insert dash line as second line in table"
|
||||
\fBinsertdash < \fItable-without-dashline\fR
|
||||
.PP
|
||||
.II "table^insert dash line"
|
||||
.II "dash line^insert"
|
||||
The command
|
||||
.B insertdash
|
||||
writes a line of dashes (hyphens) as the second line of the table.
|
||||
It makes the dash line
|
||||
by copying the head line and turning every character in the
|
||||
first into a hyphen except the tabs.
|
||||
.PP
|
||||
This command is useful for files created by the system or non-COHERENT
|
||||
programs that do not have the dash line.
|
||||
However, you will also need to convert field separators into tabs.
|
||||
.II sed
|
||||
.II tr
|
||||
You can do this with the COHERENT commands
|
||||
.B tr
|
||||
or
|
||||
.BR sed .
|
||||
.SH Example
|
||||
.B insertdash
|
||||
assumes a table that resembles the following:
|
||||
.DM
|
||||
Item Amount Cost Value Description
|
||||
1 3 50 150 rubber gloves
|
||||
.DE
|
||||
.PP
|
||||
After running
|
||||
.B insertdash
|
||||
on it, this table looks like this:
|
||||
.DM
|
||||
Item Amount Cost Value Description
|
||||
---- ------ ---- ----- --------------
|
||||
1 3 50 150 rubber gloves
|
||||
.DE
|
||||
.SH "See Also"
|
||||
.B
|
||||
dashline,
|
||||
headoff,
|
||||
headon
|
||||
.R
|
||||
.br
|
||||
COHERENT Lexicon:
|
||||
.B
|
||||
sed,
|
||||
tr
|
||||
.R
|
||||
.SO insertdash
|
||||
@@ -0,0 +1,79 @@
|
||||
.TH intersect "" "" "/rdb Command"
|
||||
.PC "Write table of rows that are in both input tables"
|
||||
\fBintersect \fItable1 table2\fR
|
||||
.PP
|
||||
.II "
|
||||
.II sort
|
||||
.II uniq
|
||||
.II "table^intersect"
|
||||
.II "table^logical AND"
|
||||
.II "intersection of tables"
|
||||
The command
|
||||
.B intersect
|
||||
is a shell script that uses the COHERENT commands
|
||||
.B sort
|
||||
and
|
||||
.B uniq
|
||||
to perform a logical AND on two tables.
|
||||
It produces a new table that consists only of the rows that
|
||||
are in both of the input tables.
|
||||
The two input tables must have the same number of columns
|
||||
(called \fIunion compatible\fR), and
|
||||
rows must match exactly to be considered the same.
|
||||
.SH Example
|
||||
Consider the table
|
||||
.BR journal ,
|
||||
which appears as follows:
|
||||
.DM
|
||||
Date Amount Account Ref Description
|
||||
------- ------- ------- ------- --------------------------------
|
||||
820107 14.00 meal v meal with jones
|
||||
820114 81.80 insur c car insurance allstate
|
||||
820119 81.72 vitamin c sundown vitamins
|
||||
820121 20.83 meal v meal with scott
|
||||
820121 2500.00 keogh c keogh payment
|
||||
820125 99.00 dues v dues to uni-ops unix conference
|
||||
.DE
|
||||
.PP
|
||||
And consider the table
|
||||
.BR carexpense ,
|
||||
which appears as follows:
|
||||
.DM
|
||||
Date Amount Account Ref Description
|
||||
------- ------- ------- ------- --------------------------------
|
||||
820113 101.62 car v car repairs
|
||||
820114 81.80 insur c car insurance allstate
|
||||
820114 93.00 car c car registration dmv
|
||||
.DE
|
||||
.PP
|
||||
To see if any rows in
|
||||
.B journal
|
||||
are also in
|
||||
.BR carexpense ,
|
||||
type the command:
|
||||
.DM
|
||||
intersect journal carexpense
|
||||
.DE
|
||||
.PP
|
||||
In this example, you would see the following on the standard output:
|
||||
.DM
|
||||
Date Amount Account Ref Description
|
||||
------- ------- ------- ------- --------------------------------
|
||||
820114 81.80 insur c car insurance allstate
|
||||
.DE
|
||||
.PP
|
||||
As you can see, the insurance expense was already posted to the
|
||||
general journal.
|
||||
.SH "See Also"
|
||||
.B
|
||||
difference,
|
||||
jointable,
|
||||
union
|
||||
.R
|
||||
.br
|
||||
COHERENT Lexicon:
|
||||
.B
|
||||
sort,
|
||||
uniq
|
||||
.R
|
||||
.SO intersect
|
||||
@@ -0,0 +1,54 @@
|
||||
.TH invoice "" "" "/act/sales Command"
|
||||
.PC "Print invoice for a sale order"
|
||||
.B invoice
|
||||
.PP
|
||||
.II "print invoice"
|
||||
The command
|
||||
.B invoice
|
||||
is part of the accounting/sales system that is included with
|
||||
.BR /rdb .
|
||||
It prompts for the number of a sales order and then prints an invoice
|
||||
for that order.
|
||||
.SH Example
|
||||
The following walks you through an example session with
|
||||
.BR invoice :
|
||||
.DM
|
||||
Please enter order number (or Return to exit): \fB1\fP
|
||||
Invoice
|
||||
-------
|
||||
Makeapile, Inc., 123 Bigbucks Blvd., Dallas, TX 12345, 1-800-SOF-WARE
|
||||
.DE
|
||||
.DM
|
||||
Order Number 1
|
||||
Date Ordered 850723
|
||||
Date Shipped 0
|
||||
.DE
|
||||
.DM
|
||||
Mailing Address for Customer Number 2
|
||||
Customer Number 2
|
||||
Mr. Thomas Boomer President
|
||||
.DE
|
||||
.DM
|
||||
Ye Olde Thermonuclear Bombe Shoppe
|
||||
54321 Blooy Road
|
||||
Livermore, California USA
|
||||
.DE
|
||||
.DM
|
||||
Order Number Code Backord Qty Price Total Name
|
||||
------- ------- ------- ------- ------- ------- ------- ----
|
||||
1 1 rdb 10 1 1500 1500.00 /rdb
|
||||
.DE
|
||||
.DM
|
||||
Gross 1500.00
|
||||
Tax 75.00
|
||||
Total 1575.00
|
||||
.DE
|
||||
.DM
|
||||
Please enter order number (or Return to exit):
|
||||
.DE
|
||||
.SH "See Also"
|
||||
.B
|
||||
act,
|
||||
cstate
|
||||
.R
|
||||
.SO invoice
|
||||
@@ -0,0 +1,405 @@
|
||||
.TH jointable "" "" "/rdb Command"
|
||||
.PC "Join two tables into one where keys match"
|
||||
\fBjointable [\-a[1|2]] [\-j[1|2] \fIcolumn\fB]... \-n \-] \fItable1 \fB[\fItable2\fB]\fR
|
||||
.PP
|
||||
.II "table^join two t."
|
||||
.II "join tables"
|
||||
The command
|
||||
.B jointable
|
||||
joins
|
||||
.I table1
|
||||
to
|
||||
.I table2
|
||||
on
|
||||
.IR column ,
|
||||
which is common to both tables (called the \fIkey column\fR).
|
||||
If no
|
||||
.I column
|
||||
is named,
|
||||
.B jointable
|
||||
assumes that the first column in each table is the key column.
|
||||
.PP
|
||||
Each table must be sorted on the key column.
|
||||
.B jointable
|
||||
writes a new table that has one row for the rows in the tables
|
||||
whose values in the key column match.
|
||||
The columns of the new table are all the columns in
|
||||
.I table1
|
||||
followed by all the columns in
|
||||
.IR table2 \(em
|
||||
with the sole exception that the key column is not repeated.
|
||||
.PP
|
||||
This is called a
|
||||
.IR "natural join" .
|
||||
An
|
||||
.I equi-join
|
||||
repeats the key column.
|
||||
.PP
|
||||
The COHERENT system's command
|
||||
.B join
|
||||
will also join two tables in the manner described above, but
|
||||
it does not know about
|
||||
.B /rdb
|
||||
head lines.
|
||||
.SH "String vs. Numeric Sort"
|
||||
The commonest problem seen with
|
||||
.B jointable
|
||||
is when users attempt to join tables that have been sorted
|
||||
.I numerically
|
||||
on the key columns (that is, the columns
|
||||
that the tables are going to be joined on).
|
||||
They use
|
||||
.B sorttable
|
||||
with the
|
||||
.B \-n
|
||||
option (for numeric) to sort a table, then call
|
||||
.B jointable.
|
||||
.BR jointable ,
|
||||
however, expects to see a
|
||||
.I "string sort"
|
||||
fails to join the tables correctly.
|
||||
.PP
|
||||
The following compares a string sort with a numeric sort:
|
||||
.DS
|
||||
.ta 0.5iC 2.0iC
|
||||
\fIString Numeric\fR
|
||||
1 1
|
||||
10 2
|
||||
2 10
|
||||
20 20
|
||||
.DE
|
||||
.PP
|
||||
Can you see why?
|
||||
Numeric is the way we count and is obviously correct.
|
||||
But string sort looks at the first character, then the second.
|
||||
A space sorts ahead of `0', so `1' comes before ``10''.
|
||||
More importantly, `1' comes before `2'
|
||||
regardless of the characters to the right.
|
||||
That is why ``10'' comes before ``2'' followed by a space.
|
||||
This problem shows up as empty output from a
|
||||
.BR jointable ,
|
||||
when you know some of the rows should be joined.
|
||||
.PP
|
||||
Right-justification makes numeric and string sorts the same.
|
||||
The leading spaces help the string sort to sort numbers correctly.
|
||||
.PP
|
||||
To make it easy for users to avoid this problem,
|
||||
.B jointable
|
||||
has the option
|
||||
.BR \-n ,
|
||||
for symmetry with the COHERENT command
|
||||
.BR sort .
|
||||
.PP
|
||||
If you want to join two tables through a numeric key column,
|
||||
you must either call the
|
||||
.B sorttable
|
||||
without its
|
||||
.B \-n
|
||||
numeric sort option, so that
|
||||
it defaults to string sort;
|
||||
or if you use the
|
||||
.B \-n
|
||||
option for
|
||||
.BR sorttable ,
|
||||
be sure to use it also with
|
||||
.BR jointable .
|
||||
.SH Options
|
||||
.B jointable
|
||||
recognizes the following options:
|
||||
.IP \fB\-a\fIn\fR
|
||||
All or one of the files (1 or 2) is output,
|
||||
whether it matches or not.
|
||||
In addition to the normal output,
|
||||
.B jointable
|
||||
produces a line for each unpairable line in file
|
||||
.IR n ,
|
||||
where
|
||||
.I n
|
||||
is 1 or 2.
|
||||
For example, the command
|
||||
.DM
|
||||
jointable -a1 ledger chart
|
||||
.DE
|
||||
.sp \n(pDu
|
||||
forces
|
||||
.B jointable
|
||||
to print every row in table
|
||||
.BR ledger ,
|
||||
regardless of whether any value in
|
||||
.BR ledger 's
|
||||
.B Account
|
||||
column matches any value in
|
||||
.BR chart 's
|
||||
.B Account
|
||||
column.
|
||||
.IP "\fB\-j\fIn column\fR
|
||||
Join on the
|
||||
.I column
|
||||
column in table number
|
||||
.I n.
|
||||
If
|
||||
.I n
|
||||
is missing, use the
|
||||
.I column
|
||||
column in each table.
|
||||
For example, the command
|
||||
.DM
|
||||
jointable -j1 Account -j2 account ledger chart
|
||||
.DE
|
||||
.sp \n(pDu
|
||||
joins tables
|
||||
.B ledger
|
||||
and
|
||||
.B chart
|
||||
using the
|
||||
.B Account
|
||||
column in
|
||||
.B ledger
|
||||
and the
|
||||
.B account
|
||||
column in
|
||||
.BR chart .
|
||||
If no columns are specified with this option,
|
||||
.B jointable
|
||||
joins the tables by the first column in each.
|
||||
Thus, this option lets you join on any column defined
|
||||
in either file, even when they have different names and locations.
|
||||
.IP \fB-n\fR
|
||||
Numeric join.
|
||||
This means that table1 and table2 were sorted with the numeric option
|
||||
.BR \-n .
|
||||
Remember that if you use
|
||||
.B \-n
|
||||
with the command
|
||||
.BR sorttable ,
|
||||
you must also use
|
||||
it with
|
||||
.BR jointable .
|
||||
.IP \fB\-\fR
|
||||
Read the standard input in place of a table.
|
||||
For example, the command
|
||||
.DM
|
||||
sorttable < journal | jointable - chart
|
||||
.DE
|
||||
.sp \n(pDu
|
||||
means to sort table
|
||||
.BR journal ,
|
||||
then join it with table
|
||||
.B chart
|
||||
so that
|
||||
.B journal
|
||||
is on the left of the output table and
|
||||
.B chart
|
||||
is on the right.
|
||||
.sp \n(pDu
|
||||
Note that this option is used only in place of
|
||||
.IR table1 .
|
||||
If
|
||||
.I table2
|
||||
is absent from the command line,
|
||||
.B jointable
|
||||
automatically reads the standard input for that table's data.
|
||||
.PP
|
||||
Note that most of these options are about
|
||||
the same as for the COHERENT command
|
||||
.BR join .
|
||||
.SH Example
|
||||
Consider table
|
||||
.BR chart ,
|
||||
as follows:
|
||||
.DM
|
||||
Account Name
|
||||
------- ----
|
||||
100 Assets
|
||||
101 Cash
|
||||
111 Accounts Receivable
|
||||
111.1 Allowance for Bad Debt
|
||||
115 Notes Receivable
|
||||
120 Deposits
|
||||
130 Parts Inventory
|
||||
...
|
||||
.DE
|
||||
.PP
|
||||
and table
|
||||
.BR ledger ,
|
||||
as follows:
|
||||
.DM
|
||||
Account Date Debit Credit
|
||||
------- ---- ----- ------
|
||||
101 820102 25000
|
||||
101 820103 5000
|
||||
101 820104 15000
|
||||
130 820104 30000
|
||||
150.1 820103 10000
|
||||
201.1 820104 15000
|
||||
211.1 820102 25000
|
||||
211.2 820103 5000
|
||||
.DE
|
||||
.PP
|
||||
Note that each is sorted in string fashion on its first column.
|
||||
To join them, use the command:
|
||||
.DM
|
||||
jointable ledger chart
|
||||
.DE
|
||||
.PP
|
||||
This joins the tables on the first column in each, and writes the
|
||||
following to the standard output:
|
||||
.DM
|
||||
Account Date Debit Credit Name
|
||||
------- ---- ----- ------ ----
|
||||
101 820102 25000 Cash
|
||||
101 820103 5000 Cash
|
||||
101 820104 15000 Cash
|
||||
130 820104 30000 Parts Inventory
|
||||
150.1 820103 10000 Test equipment
|
||||
211.1 820102 25000 Notes Payable - BA
|
||||
211.2 820103 5000 Notes Payable - Z Equip
|
||||
.DE
|
||||
.PP
|
||||
As you can see, column
|
||||
.B Name
|
||||
has been added to the columns of the
|
||||
.B ledger
|
||||
table, and that column
|
||||
.B Account
|
||||
is not repeated.
|
||||
Also note that
|
||||
.B jointable
|
||||
wrote only the rows whose values in column
|
||||
.B Account
|
||||
match.
|
||||
If a table has several rows with repeated key values (e.g., the
|
||||
three
|
||||
.BR 101 s
|
||||
in the
|
||||
.B Account
|
||||
column), the joined table's rows are also repeated (see the three
|
||||
.BR Cash s
|
||||
in column
|
||||
.BR Name ).
|
||||
.PP
|
||||
If you have a table named
|
||||
.B journal
|
||||
that is sorted on column
|
||||
.BR Account ,
|
||||
as follows
|
||||
.DM
|
||||
Date Account Debit Credit
|
||||
---- ------- ----- ------
|
||||
820104 101 15000
|
||||
820103 101 5000
|
||||
820102 101 25000
|
||||
820104 130 30000
|
||||
820103 150.1 10000
|
||||
820104 201.1 15000
|
||||
820102 211.1 25000
|
||||
820103 211.2 5000
|
||||
.DE
|
||||
.PP
|
||||
you could join it with table
|
||||
.B chart
|
||||
by typing this command:
|
||||
.DM
|
||||
jointable -j Account journal chart
|
||||
.DE
|
||||
.PP
|
||||
The following gives
|
||||
another way for the same result (because
|
||||
.BR chart 's
|
||||
join column defaults to column 1):
|
||||
.DM
|
||||
jointable -j1 Account journal chart
|
||||
.DE
|
||||
.PP
|
||||
Both commands produce the following output:
|
||||
.DM
|
||||
Date Account Debit Credit Name
|
||||
------ ------- ----- ------ ----
|
||||
820104 101 15000 Cash
|
||||
820103 101 5000 Cash
|
||||
820102 101 25000 Cash
|
||||
820104 130 30000 Parts Inventory
|
||||
820103 150.1 10000 Test equipment
|
||||
820102 211.1 25000 Notes Payable - Bank of Amerigold
|
||||
820103 211.2 5000 Notes Payable - Z Equipment
|
||||
.DE
|
||||
.PP
|
||||
The
|
||||
.B \-a
|
||||
option lets you see all of one table whether or not there is a match.
|
||||
For example, the command
|
||||
.DM
|
||||
jointable -a1 ledger chart
|
||||
.DE
|
||||
.PP
|
||||
writes the following:
|
||||
.DM
|
||||
Account Date Debit Credit Name
|
||||
------- ---- ----- ------ ----
|
||||
101 820102 15000 Cash
|
||||
101 820103 5000 Cash
|
||||
101 820104 25000 Cash
|
||||
130 820104 30000 Parts Inventory
|
||||
150.1 820103 10000 Test equipment
|
||||
201.1 820104 15000
|
||||
211.1 820102 25000 Notes Payable - Bank of Amerigold
|
||||
211.2 820103 5000 Notes Payable - Z Equipment
|
||||
.DE
|
||||
.PP
|
||||
Note that column
|
||||
.BR Account 's
|
||||
value
|
||||
.B 201.1
|
||||
in the ledger shows up here, even though it is not in
|
||||
.BR chart .
|
||||
This shows us that
|
||||
.B 201.1
|
||||
is an error.
|
||||
All account numbers should be in the chart of accounts.
|
||||
We should either add
|
||||
.B 201.1
|
||||
to the chart of accounts, or find
|
||||
the correct number in the chart of accounts and replace
|
||||
.B 201.1
|
||||
in the
|
||||
.B journal
|
||||
with the correct account number.
|
||||
.PP
|
||||
If you pipe a file into a
|
||||
.BR jointable ,
|
||||
you can control which table it will be (first or second) by using the
|
||||
dash option.
|
||||
For example:
|
||||
.DM
|
||||
sorttable Account < journal | jointable -j Account - chart
|
||||
.DE
|
||||
.PP
|
||||
This produces the following output:
|
||||
.DM
|
||||
Date Account Debit Credit Name
|
||||
---- ------- ----- ------ ----
|
||||
820103 101 5000 Cash
|
||||
820104 101 15000 Cash
|
||||
820102 101 25000 Cash
|
||||
820104 130 30000 Parts Inventory
|
||||
820103 150.1 10000 Test equipment
|
||||
820102 211.1 25000 Notes Payable - Bank of Amerigold
|
||||
820103 211.2 5000 Notes Payable - Z Equipment
|
||||
.DE
|
||||
.PP
|
||||
Note the
|
||||
.B \-
|
||||
before
|
||||
.BR chart .
|
||||
It says that the standard input file
|
||||
will be file 1 or on the left side of the table.
|
||||
.SH "See Also"
|
||||
.B
|
||||
column,
|
||||
sorttable
|
||||
.R
|
||||
.br
|
||||
COHERENT Lexicon:
|
||||
.B
|
||||
join
|
||||
.R
|
||||
@@ -0,0 +1,19 @@
|
||||
.TH julian "" "" "/rdb Command"
|
||||
.PC "Convert column of dates for arithmetic and format change
|
||||
\fBjulian [ -ceu ] [ \fIColumn ... \fB] < \fItableorlist\fR
|
||||
.PP
|
||||
.II "date^convert"
|
||||
.II "Julian dates"
|
||||
.II "date^Julian"
|
||||
The command
|
||||
.B julian
|
||||
converts Gregorian dates in one or more columns to Julian format.
|
||||
For details on the differences between Gregorian and Julian dates, and
|
||||
how to use these commands in scripts, see the manual entry for the command
|
||||
.BR gregorian .
|
||||
.SH "See Also"
|
||||
.B
|
||||
computedate,
|
||||
gregorian,
|
||||
todaydate
|
||||
.R
|
||||
+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
|
||||
@@ -0,0 +1,63 @@
|
||||
.TH label "" "" "/rdb Command"
|
||||
.PC "Print mailing labels from a mailing list"
|
||||
\fBlabel < \fIlist\fR
|
||||
.PP
|
||||
.II "print mailing labels"
|
||||
The command
|
||||
.B label
|
||||
prints mailing labels from a mailing list, in list format.
|
||||
This command is obsolete because the command
|
||||
.B report
|
||||
can make labels more easily; but it is
|
||||
is retained as an example of shell programming.
|
||||
.PP
|
||||
.B label
|
||||
is a shell script so you can change it easily
|
||||
to handle different lists and labels.
|
||||
.SH Example
|
||||
If you had a file called
|
||||
.B maillist
|
||||
that looked 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 \n(pDu
|
||||
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
|
||||
The command
|
||||
.DM
|
||||
label < maillist
|
||||
.DE
|
||||
.PP
|
||||
generates mailing labels that look like this:
|
||||
.DM
|
||||
Ronald McDonald
|
||||
McDonald's
|
||||
123 Mac Attack
|
||||
Memphis, TENN 30000
|
||||
.sp 2
|
||||
Chiquita Banana
|
||||
United Brands
|
||||
Uno Avenido de la Reforma
|
||||
San Jose, Costa Rica 123456789
|
||||
.DE
|
||||
.SH "See Also"
|
||||
.B
|
||||
letter,
|
||||
report
|
||||
.R
|
||||
.SO label
|
||||
@@ -0,0 +1,54 @@
|
||||
.TH length "" "" "/rdb Command"
|
||||
.PC "Return the length of its argument or input file"
|
||||
\fBlength [\fIstring\fB] [< \fIfile\fB]\fR
|
||||
.PP
|
||||
.II "length of string"
|
||||
.II "string^length"
|
||||
The command
|
||||
.B length
|
||||
outputs the number of characters in its first argument.
|
||||
If there
|
||||
is no argument, it reads the standard input.
|
||||
.PP
|
||||
Because
|
||||
.B length
|
||||
counts only its first argument, you must put quotation marks
|
||||
around all of the words on the command line to make them one argument.
|
||||
.PP
|
||||
.II wc
|
||||
.B length
|
||||
uses
|
||||
.B "wc -c"
|
||||
to do the counting.
|
||||
.SH Example
|
||||
Here we find the length of a string and a file.
|
||||
.DM
|
||||
length aA1
|
||||
.DE
|
||||
.PP
|
||||
This returns \fB3\fR.
|
||||
.PP
|
||||
The next command
|
||||
.DM
|
||||
length 'word1 word2'
|
||||
.DE
|
||||
.PP
|
||||
returns \fB11\fR \(em that is, the length of
|
||||
.B word1
|
||||
plus
|
||||
.B word2
|
||||
plus the space between them.
|
||||
.PP
|
||||
The final example measures the number of characters in file
|
||||
.BR length.1 :
|
||||
.DM
|
||||
length < length.1
|
||||
.DE
|
||||
.PP
|
||||
Note that you need must quote strings if they have spaces or tabs in them.
|
||||
.SH "See Also"
|
||||
COHERENT Lexicon:
|
||||
.B
|
||||
wc
|
||||
.R
|
||||
.SO length
|
||||
+150
@@ -0,0 +1,150 @@
|
||||
.TH letter "" "" "/rdb Command"
|
||||
.PC "Print form letters from a mailing list"
|
||||
\fBletter \fIletter.1 ... \fB< \fImaillist\fR
|
||||
.PP
|
||||
.II "print letters"
|
||||
.II "letters, print"
|
||||
The command
|
||||
.B letter
|
||||
prints form letters from a standard letter and a mailing list.
|
||||
It is obsolete, because the command
|
||||
.B report
|
||||
is so much more powerful and easier to use; but it is retained for
|
||||
compatibility and as an example of shell programming.
|
||||
.PP
|
||||
.B letter
|
||||
is a shell script, so you can be easily changed it
|
||||
to handle different lists and letters.
|
||||
To modify it, copy
|
||||
.B letter
|
||||
from
|
||||
.B $RDB/bin/letter
|
||||
to your local directory, then use your text editor to edit it.
|
||||
Then you can modify it with a text editor
|
||||
to handle any special features of your mailing list and letters.
|
||||
.SH Example
|
||||
If you have a file called
|
||||
.B maillist
|
||||
that looks like this:
|
||||
.DM
|
||||
Name Ronald McDonald
|
||||
Company McDonald's
|
||||
Street 123 Mac Attack
|
||||
City Memphis
|
||||
State TENN
|
||||
ZIP 30000
|
||||
Phone (111) 222-3333
|
||||
.sp \n(pDu
|
||||
Name Chiquita Banana
|
||||
Company United Brands
|
||||
Street Uno Avenido de la Reforma
|
||||
City San Jose
|
||||
State Costa Rica
|
||||
ZIP 123456789
|
||||
Phone 1234
|
||||
.DE
|
||||
.PP
|
||||
Assume, too, that the two parts of your letter are in two files.
|
||||
.B letter.1
|
||||
contains:
|
||||
.DM
|
||||
We have a new product that we want to sell to everyone at
|
||||
.DE
|
||||
.PP
|
||||
And
|
||||
.B letter.2
|
||||
contains:
|
||||
.DM
|
||||
Please have everyone send us an order. We will be very grateful.
|
||||
.sp \n(pDu
|
||||
Sincerely,
|
||||
.sp \n(pDu
|
||||
Mr. Marketing
|
||||
Makeapile, Inc.
|
||||
.DE
|
||||
.PP
|
||||
To assemble the letter files and the mailing list into one set of
|
||||
mail-merged letters, type the following command:
|
||||
.DM
|
||||
letter letter.1 letter.2 < maillist
|
||||
.DE
|
||||
.PP
|
||||
This produces:
|
||||
.DM
|
||||
Ronald McDonald
|
||||
McDonald's
|
||||
123 Mac Attack
|
||||
Memphis, TENN 30000
|
||||
.sp
|
||||
Dear Ronald McDonald:
|
||||
.sp \n(pDu
|
||||
We have a new product that we want to sell to everyone at
|
||||
McDonald's. Please have everyone send us an order. We will be
|
||||
very grateful.
|
||||
.sp
|
||||
Sincerely,
|
||||
.sp \n(pDu
|
||||
Mr. Marketing
|
||||
Makeapile, Inc.
|
||||
.sp \n(pDu
|
||||
\fI< ... spaces to bottom of letter ... >
|
||||
.DE
|
||||
.DM
|
||||
Chiquita Banana
|
||||
United Brands
|
||||
Uno Avenido de la Reforma
|
||||
San Jose, Costa Rica 123456789
|
||||
.sp
|
||||
Dear Chiquita Banana:
|
||||
.sp \n(pDu
|
||||
We have a new product that we want to sell to everyone at United
|
||||
Brands. Please have everyone send us an order. We will be very
|
||||
grateful.
|
||||
.sp \n(pDu
|
||||
Sincerely,
|
||||
Mr. Marketing
|
||||
Makeapile, Inc.
|
||||
.sp \n(pDu
|
||||
\fI< ... spaces to bottom of letter ... >
|
||||
.DE
|
||||
.PP
|
||||
The following sample letter program prints out the mailing name
|
||||
and address, and the salutation \fBDear \fIName\fR.
|
||||
It then \fBcat\fRs
|
||||
.BR letter.1 ,
|
||||
echos the company name, and finally cats
|
||||
.BR letter.2 .
|
||||
.B letter
|
||||
writes its output to temporary file
|
||||
.BR TMP ,
|
||||
then
|
||||
.BR nroff 's
|
||||
the
|
||||
.B TMP
|
||||
file to the standard output.
|
||||
.B nroff
|
||||
reformats the file
|
||||
(left and right justified) for each company name's length.
|
||||
.PP
|
||||
By studying the
|
||||
.B letter
|
||||
shell script and the COHERENT shell's documentation
|
||||
.B (sh
|
||||
or
|
||||
.BR ksh) ,
|
||||
you can assemble fancy, complex form letters.
|
||||
.SH "See Also"
|
||||
.B
|
||||
label,
|
||||
report
|
||||
.R
|
||||
.br
|
||||
COHERENT Lexicon:
|
||||
.B
|
||||
cat,
|
||||
ksh,
|
||||
nroff,
|
||||
troff,
|
||||
sh
|
||||
.R
|
||||
.SO letter
|
||||
@@ -0,0 +1,25 @@
|
||||
.TH like "" "" "/rdb Command"
|
||||
.PC "Find names that sound like another name"
|
||||
\fBlike \fIsimilar-name file \fB[ \fIname-column \fB]\fR
|
||||
.PP
|
||||
.II soundex
|
||||
.II "name, convert to soundex"
|
||||
.II "convert name to soundex"
|
||||
.II "Knuth, Donald"
|
||||
The command
|
||||
.B like
|
||||
converts a name to Knuth's soundex code and looks it up in the
|
||||
.B .x
|
||||
secondary-index file of a name.
|
||||
To work, you must have first run the command
|
||||
.BR soundex ,
|
||||
to create the soundex file.
|
||||
.SH Example
|
||||
See
|
||||
.B soundex
|
||||
for examples.
|
||||
.SH "See Also"
|
||||
.B
|
||||
soundex
|
||||
.R
|
||||
.SO like
|
||||
@@ -0,0 +1,66 @@
|
||||
.TH listtosh "" "" "/rdb Command"
|
||||
.PC "Convert list format to shell variable"
|
||||
\fBlisttosh < \fIlist\fR
|
||||
.PP
|
||||
.II "list^convert to shell"
|
||||
.II "convert list to shell"
|
||||
The command
|
||||
.B listtosh
|
||||
converts a list-format file (\fIcolumn\fB<tab>\fIdata\fR)
|
||||
to a shell variable format
|
||||
(\fBVARIABLE='\fIvalue\fB'\fR).
|
||||
You can use this to move a record into a shell variable.
|
||||
.SH Example
|
||||
Consider file
|
||||
.BR maillist :
|
||||
.DM
|
||||
Number 1
|
||||
Name Ronald McDonald
|
||||
Company McDonald's
|
||||
Street 123 Mac Attack
|
||||
City Menphis
|
||||
State TENN
|
||||
ZIP 30000
|
||||
Phone (111) 222-3333
|
||||
.sp \n(pDu
|
||||
Number 2
|
||||
Name Chiquita Banana
|
||||
Company United Brands
|
||||
Street Uno Avenito De La Revolution
|
||||
City San Jose
|
||||
State Costa Rica
|
||||
ZIP 123456789
|
||||
Phone 1234
|
||||
.DE
|
||||
.PP
|
||||
The command
|
||||
.DM
|
||||
eval `row 'Number == 2' < maillist | listtosh`
|
||||
.DE
|
||||
.PP
|
||||
transforms the mailing list into the following format:
|
||||
.DM
|
||||
Number='2'
|
||||
Name='Chiquita Banana'
|
||||
Company='United Brands'
|
||||
Street='Uno Avenito De La Revolution'
|
||||
City='San Jose'
|
||||
State='Costa Rica'
|
||||
ZIP='123456789'
|
||||
Phone='1234'
|
||||
.DE
|
||||
.PP
|
||||
Once this is done, test the transformation by typing:
|
||||
.DM
|
||||
echo "$Name's phone number is $Phone."
|
||||
.DE
|
||||
.PP
|
||||
This writes the following on the standard output:
|
||||
.DM
|
||||
Chiquita Banana's phone number is 1234.
|
||||
.DE
|
||||
.SH "See Also"
|
||||
.B
|
||||
tabletolist
|
||||
.R
|
||||
.SO listtosh
|
||||
@@ -0,0 +1,120 @@
|
||||
.TH listtotable "" "" "/rdb Command"
|
||||
.PC "Convert from list to table format"
|
||||
\fBlisttotable [ \-el ] < \fIlistfile\fR
|
||||
.PP
|
||||
.II "list^convert to table"
|
||||
.II "table^from list"
|
||||
.II "convert list to table"
|
||||
.B listtotable
|
||||
converts a file in list format to table format.
|
||||
Some
|
||||
.B /rdb
|
||||
programs must see files in table format,
|
||||
so the conversion is necessary.
|
||||
.PP
|
||||
In addition, table-formatted files are processed faster than
|
||||
list-formatted files.
|
||||
Any time you send a list-formatted file through a pipe of two
|
||||
or more programs, even if they can handle list format, convert
|
||||
them to table format so that the programs
|
||||
in the pipe will run two or three times faster on average.
|
||||
.PP
|
||||
The reason that table-formatted files run so much faster
|
||||
is that a list file is often two or three times larger
|
||||
than a table because of the repeated column names.
|
||||
Therefore, when handling list-formatted files, the programs
|
||||
have to process two or three times as many characters.
|
||||
.SH Options
|
||||
.B listtotable
|
||||
recognizes the following options:
|
||||
.IP \fB\-e\fR 0.3i
|
||||
Expand each column to next tab stop.
|
||||
Ordinarily, table columns heads are only as wide as list column heads.
|
||||
.IP \fB\-l\fR
|
||||
No head line in the list file.
|
||||
This option makes it possible to convert and sometimes
|
||||
use the older list-formatted files.
|
||||
.sp \n(pDu
|
||||
Earlier versions of
|
||||
.B /rdb
|
||||
did not require the leading newline in the list-formatted file; however,
|
||||
this requirement was added by later editions of
|
||||
.B /rdb
|
||||
to make it easy for its commands to distinguish a list file from a table.
|
||||
.SH "List and Table-Format Rules"
|
||||
List format 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
|
||||
.DE
|
||||
.DM
|
||||
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
|
||||
Remember there are three rules for constructing a list-format file:
|
||||
.IP \fB1.\fR 0.3i
|
||||
The
|
||||
first character in the file is a newline.
|
||||
Be sure that there are no
|
||||
unseen spaces, tabs, or nonprinting characters on the first
|
||||
line, or things will get quite messed up.
|
||||
.IP \fB2.\fR
|
||||
Each line consists of two columns separated by a tab.
|
||||
The first column is gives the column's
|
||||
name, and the second column gives its values.
|
||||
.IP \fB3.\fR
|
||||
A newline character follows each
|
||||
.I row
|
||||
(record).
|
||||
.PP
|
||||
And there are three rules for contructing a table, as follows:
|
||||
.IP \fB1.\fR 0.3i
|
||||
One tab between each column in a row, and a newline at the end.
|
||||
.IP \fB2.\fR
|
||||
Name of the column at the top of the column, in the first line of the file.
|
||||
.IP \fB3.\fR
|
||||
A dash line as the second line in the file.
|
||||
.SH Example
|
||||
The command
|
||||
.DM
|
||||
listtotable < maillist
|
||||
.DE
|
||||
.PP
|
||||
converts list file
|
||||
.B maillist
|
||||
into table format.
|
||||
The result appears as follows:
|
||||
.DM
|
||||
Number Name Company Street City State ZIP Phone
|
||||
------- ------- ------- ------- ------- ------- ------- -------
|
||||
1 Ronald McDonald McDonald's 123 Mac Attack Memphis
|
||||
TENN 30000 (111) 222-3333
|
||||
2 Chiquita Banana United Brands Uno Avenito De La
|
||||
Revolution San Jose Costa Rica 123456789 1234
|
||||
.DE
|
||||
.PP
|
||||
When you look at this messy table,
|
||||
you can see the need for list format.
|
||||
The information in each column is often too wide for the screen and
|
||||
wraps around to the next line.
|
||||
.SH "See Also"
|
||||
.B
|
||||
tabletolist
|
||||
.R
|
||||
.SH Notes
|
||||
If you use this command with a table instead of a list file, you
|
||||
will see a mess.
|
||||
@@ -0,0 +1,95 @@
|
||||
.TH lock "" "" "/rdb Command"
|
||||
.PC "Lock a record or field of a file"
|
||||
\fBlock \fIfilename processid from to indexfrom indexto\fR
|
||||
.PP
|
||||
.II "record locking"
|
||||
The command
|
||||
.B lock
|
||||
locks
|
||||
.I filename
|
||||
by writing a row into the lock file \fB/tmp/L\fIfilename\fR,
|
||||
which contains one line for each locked record or field.
|
||||
Its command line contains the following arguments:
|
||||
.IP \fIprocessid\fR
|
||||
The process identifier of the program that locks
|
||||
.IR filename .
|
||||
.IP \fIfrom\fR
|
||||
The beginning point of the bytes to be locked.
|
||||
.IP \fIto\fR
|
||||
The end point of the bytes to be locked.
|
||||
.IP \fIindexbegin\fR
|
||||
The beginning point of the index entry for the data being locked.
|
||||
.IP \fIindexend\fR
|
||||
The end point of the index entry for the data being locked.
|
||||
.PP
|
||||
When a process attempts to lock a string of bytes that is already locked,
|
||||
.B lock
|
||||
returns an error condition.
|
||||
You can test for this by using the COHERENT command
|
||||
.B test
|
||||
to test the shell variable \fB$?\fR.
|
||||
.SH Example
|
||||
Let's use
|
||||
.B lock
|
||||
on table
|
||||
.BR inventory ,
|
||||
which appears as follows:
|
||||
.DM
|
||||
Item Amount Cost Value Description
|
||||
---- ------ ---- ----- --------------
|
||||
1 3 50 150 rubber gloves
|
||||
2 100 5 500 test tubes
|
||||
3 5 80 400 clamps
|
||||
4 23 19 437 plates
|
||||
5 99 24 2376 cleaning cloth
|
||||
6 89 147 13083 bunsen burners
|
||||
7 5 175 875 scales
|
||||
.DE
|
||||
.PP
|
||||
First, use
|
||||
.B seek
|
||||
to locate the record and return the offset and size, as follows:
|
||||
.DM
|
||||
LOCATION=`echo 5 | seek -mb inventory Item`
|
||||
echo $LOCATION
|
||||
207 245 0 8
|
||||
.DE
|
||||
.PP
|
||||
This means that the record is offset 207 bytes into file
|
||||
.BR inventory ,
|
||||
and that it is 38 bytes long, ending at byte 245.
|
||||
The 0 and 8 mean that there is no secondary index file.
|
||||
.PP
|
||||
Now we can call
|
||||
.B lock
|
||||
to lock the record:
|
||||
.DM
|
||||
lock inventory $$ $LOCATION
|
||||
.DE
|
||||
.PP
|
||||
Note that we use the shell variable
|
||||
.B $LOCATION
|
||||
to supply the arguments
|
||||
.I from
|
||||
and
|
||||
.IR to .
|
||||
We also use the built-in shell variable \fB$$\fR to
|
||||
write the process identifier on the command line.
|
||||
.PP
|
||||
The lock
|
||||
.B /tmp/Linventory
|
||||
has the following contents:
|
||||
.DM
|
||||
207 245 0 8
|
||||
.DE
|
||||
.SH "See Also"
|
||||
.B
|
||||
seek,
|
||||
unlock
|
||||
.R
|
||||
.br
|
||||
COHERENT Lexicon:
|
||||
.B
|
||||
test
|
||||
.R
|
||||
.SO lock
|
||||
@@ -0,0 +1,56 @@
|
||||
.TH lowercase "" "" "/rdb Command"
|
||||
.PC "Transform text to lower case"
|
||||
\fBlowercase [\fIstring ...\fB] [< \fIfile\fB]\fR
|
||||
.PP
|
||||
.II "string^convert to lower case"
|
||||
.II "convert string to lower case"
|
||||
The command
|
||||
.B lowercase
|
||||
converts to lower case every letter in
|
||||
.I string
|
||||
or
|
||||
.IR file .
|
||||
If there are no arguments, it reads and converts the standard input.
|
||||
It uses
|
||||
.BR tr ,
|
||||
the COHERENT character-translation command, to do the converting.
|
||||
.SH Example
|
||||
The command:
|
||||
.DM
|
||||
lowercase BIG WORDS
|
||||
.DE
|
||||
.PP
|
||||
prints
|
||||
.DM
|
||||
big words
|
||||
.DE
|
||||
.PP
|
||||
on the standard output.
|
||||
.PP
|
||||
If the file
|
||||
.B CAPITALS
|
||||
contains the string
|
||||
.DM
|
||||
THESE ARE ALL CAPS.
|
||||
.DE
|
||||
.PP
|
||||
then the command
|
||||
.DM
|
||||
lowercase < CAPITALS
|
||||
.DE
|
||||
.PP
|
||||
prints on the standard output:
|
||||
.DM
|
||||
these are all caps.
|
||||
.DE
|
||||
.SH "See Also"
|
||||
.B
|
||||
cap,
|
||||
uppercase
|
||||
.R
|
||||
.br
|
||||
COHERENT Lexicon:
|
||||
.B
|
||||
tr
|
||||
.R
|
||||
.SO lowercase
|
||||
@@ -0,0 +1,27 @@
|
||||
.TH maximum "" "" "/rdb Command"
|
||||
.PC "Display the maximum value in a column"
|
||||
\fBmaximum [ \-l ] [ \fIcolumn ... \fB] < \fItable\fR
|
||||
.PP
|
||||
.II column^maximum value"
|
||||
The command
|
||||
.B maximum
|
||||
displays the maximum value of each
|
||||
.IR column .
|
||||
If no
|
||||
.I column
|
||||
appears on the command line,
|
||||
.B maximum
|
||||
returns the maximum value in every column in
|
||||
.IR table .
|
||||
.PP
|
||||
The \fB\-l\fR
|
||||
option writes the table to the standard output, as well as the
|
||||
minimum value for each named column.
|
||||
.SH Example
|
||||
For an example of this command, see the entry for
|
||||
.BR total .
|
||||
.SH "See Also"
|
||||
.B
|
||||
mean,
|
||||
minimum
|
||||
.R
|
||||
@@ -0,0 +1,37 @@
|
||||
.TH mean "" "" "/rdb Command"
|
||||
.PC "Display the mean of a column"
|
||||
\fBmean [ \-l ] [ \fIcolumn ... \fB] < \fItable\fR
|
||||
.PP
|
||||
.II "column^mean value"
|
||||
.B mean
|
||||
displays the mean value of each
|
||||
.IR column .
|
||||
If no
|
||||
.I column
|
||||
appears on the command line,
|
||||
.B mean
|
||||
returns the mean value for each column in
|
||||
.IR table .
|
||||
.PP
|
||||
.B mean
|
||||
assign the value of zero to a blank line.
|
||||
This changes the value of the mean.
|
||||
If that is not what you want, use the command
|
||||
.B rmblanks
|
||||
or
|
||||
.B "compress \-b"
|
||||
to remove blank lines.
|
||||
.B mean
|
||||
also treats blank values as zero
|
||||
.PP
|
||||
The option \fB\-l\fR
|
||||
prints the contents of the table, as well as the mean value for each
|
||||
named column.
|
||||
.SH Example
|
||||
For an example of this command, see the entry for
|
||||
.BR total .
|
||||
.SH "See Also"
|
||||
.B
|
||||
maximum,
|
||||
minimum
|
||||
.R
|
||||
+276
@@ -0,0 +1,276 @@
|
||||
.TH menu "" "" "/rdb Command"
|
||||
.PC "Root menu with some COHERENT commands"
|
||||
.B menu
|
||||
.PP
|
||||
.II "command^menu"
|
||||
The command
|
||||
.B menu
|
||||
displays a table of commands that you can execute by
|
||||
simply typing a number or a name.
|
||||
Menus are useful for inexperienced users.
|
||||
Experienced users can set up a menu very easily.
|
||||
.PP
|
||||
.B menu
|
||||
is a shell script that simply echos the
|
||||
.B menu
|
||||
table of choices, then waits for the user to type a number or name.
|
||||
Then
|
||||
.B menu
|
||||
uses a shell \fBcase\fR statement
|
||||
to execute a command or series of commands for each
|
||||
choice.
|
||||
To set up your own menus, simply copy the
|
||||
.B menu
|
||||
shell command from the
|
||||
.B $RDB/bin
|
||||
into your directory, then edit it.
|
||||
You should change its name to
|
||||
.B Menu
|
||||
or
|
||||
.BR Menu.something ,
|
||||
to keep from confusing
|
||||
.BR /rdb .
|
||||
.PP
|
||||
There is a sample local
|
||||
.B menu,
|
||||
named
|
||||
.B Menu
|
||||
in directory
|
||||
.BR $RDB/demo .
|
||||
.SH Example
|
||||
The following gives an example menu:
|
||||
.B1
|
||||
COHERENT MENU
|
||||
Number Name For
|
||||
------- ------- ----------------------------------------------------
|
||||
0 exit leave menu or return to higher menu
|
||||
1 Menu goto another local menu (if any)
|
||||
2 sh get COHERENT shell
|
||||
3 vi edit a file
|
||||
4 mail read mail
|
||||
5 send send mail to someone
|
||||
6 cal see your calendar
|
||||
7 who see who is on the system
|
||||
8 ls list the files in this directory
|
||||
9 cat display a file on the screen
|
||||
10 rdb display rdb commands
|
||||
.sp \n(pDu
|
||||
Enter a number or name for the action you wish or DEL to exit:
|
||||
.B2
|
||||
.PP
|
||||
.B menu
|
||||
waits for you to type your choice of number or name.
|
||||
Numbers are quicker to type, but names are more easily remembered, and
|
||||
help you learn how to do things at the shell level.
|
||||
.SH "Setting Up Your Own Menus"
|
||||
You can automate your operations with menus.
|
||||
If you have naive users who might have trouble learning or
|
||||
remembering the COHERENT or
|
||||
.B /rdb
|
||||
commands, you can set up menus for them.
|
||||
Also, when you have an operation in which a few commands
|
||||
are repeatedly executed, you can put them into a menu for simple choice.
|
||||
.PP
|
||||
You can put your menus in the directories in which they
|
||||
will be used or in your
|
||||
.B $HOME/bin
|
||||
or other
|
||||
.B bin
|
||||
directory.
|
||||
.PP
|
||||
To start, go to the directory of your choice and copy the
|
||||
.B $RDB
|
||||
.B menu
|
||||
to your directory:
|
||||
.DM
|
||||
cp $RDB/bin/menu Menu
|
||||
.DE
|
||||
.PP
|
||||
or
|
||||
.DM
|
||||
cp $RDB/demo/Menu .
|
||||
.DE
|
||||
.PP
|
||||
We suggest the convention of using the name
|
||||
.B Menu
|
||||
with the capital `M'
|
||||
so it appears at the top of your list of files when you do an
|
||||
.B lc
|
||||
command.
|
||||
.PP
|
||||
You can then name submenus; for example,
|
||||
\fBMenu.\fIother\fR
|
||||
where
|
||||
.I other
|
||||
is something that suggests the kinds of commands the menu displays.
|
||||
.PP
|
||||
Now edit the
|
||||
.B Menu
|
||||
file.
|
||||
As you study the code, you will find that it is very easy to
|
||||
create your own directory.
|
||||
.PP
|
||||
Menu is in two parts.
|
||||
The first part is the menu table:
|
||||
.DM
|
||||
cat << SCREEN
|
||||
$CLEAR COHERENT MENU
|
||||
Number Name For
|
||||
------- ------- -------------------------
|
||||
0 exit leave menu or return to higher menu
|
||||
1 Menu goto another local menu (if any)
|
||||
2 sh get unix shell
|
||||
3 vi edit a file
|
||||
4 mail read mail
|
||||
5 send send mail to someone
|
||||
6 cal see your calendar
|
||||
7 who see who is on the system
|
||||
8 ls list the files in this directory
|
||||
9 cat display a file on the screen
|
||||
10 rdb display rdb commands
|
||||
.sp \n(pDu
|
||||
Please enter a number or name for the action you wish or DEL to exit:
|
||||
.sp \n(pDu
|
||||
SCREEN
|
||||
.DE
|
||||
.PP
|
||||
The command
|
||||
.B cat
|
||||
simply sends to the screen everything
|
||||
after the command and before the line that
|
||||
begins with
|
||||
.BR SCREEN ,
|
||||
including the line that begins
|
||||
.BR "Please enter a number" .
|
||||
.PP
|
||||
The shell replaces
|
||||
.B $CLEAR
|
||||
on the first line with a sequence of characters that clears the terminal.
|
||||
.B $CLEAR
|
||||
must have been set by the following command in the
|
||||
.B menu
|
||||
or in the
|
||||
.B .profile
|
||||
file of the user:
|
||||
.DM
|
||||
.II clear
|
||||
CLEAR=`clear`
|
||||
.DE
|
||||
.PP
|
||||
The second part of
|
||||
.B Menu
|
||||
is a large
|
||||
.B case
|
||||
statement that you can edit to do what you want.
|
||||
Here is a sample:
|
||||
.DM
|
||||
.II read
|
||||
read ANSWER COMMENT
|
||||
.DE
|
||||
.DM
|
||||
.II case
|
||||
case $ANSWER in
|
||||
.DE
|
||||
.DM
|
||||
0|exit) exit 0 ;;
|
||||
1|Menu) Menu ;;
|
||||
2|sh) sh ;;
|
||||
3|vi)
|
||||
echo 'Which file or files do you wish to edit'
|
||||
read ANSWER COMMENT
|
||||
vi $ANSWER $COMMENT
|
||||
;;
|
||||
.DE
|
||||
.DM
|
||||
4|mail) mail ;;
|
||||
5|send)
|
||||
echo 'Please enter login name of person to send mail to'
|
||||
read ANSWER COMMENT
|
||||
echo 'Type you letter, and end by typing Ctrl-d'
|
||||
mail $ANSWER
|
||||
;;
|
||||
.DE
|
||||
.DM
|
||||
6|cal) (cd ; calendar) ;;
|
||||
7|who) who ;;
|
||||
8|ls) ls ;;
|
||||
9|cat)
|
||||
echo 'Please enter the name of the file you wish to see'
|
||||
read ANSWER COMMENT
|
||||
cat $ANSWER
|
||||
;;
|
||||
.DE
|
||||
.DM
|
||||
10|rdb) menu.rdb ;;
|
||||
*) echo 'Sorry, but that number or name is not recognized.' ;;
|
||||
esac
|
||||
.DE
|
||||
.PP
|
||||
The command
|
||||
.B read
|
||||
waits for the user to enter his choice.
|
||||
The first word typed is assigned to the shell variable
|
||||
.BR ANSWER .
|
||||
If the user types any more words, they are assigned to variable
|
||||
.BR COMMENT ,
|
||||
which might be used in your commands.
|
||||
.PP
|
||||
Next is the
|
||||
.B case
|
||||
statement that examines
|
||||
.B $ANSWER
|
||||
to decide which command to execute.
|
||||
Note that the number and name
|
||||
are separated by a vertical-bar character `|' to mean
|
||||
.BR or :
|
||||
.DM
|
||||
0|exit) exit 0 ;;
|
||||
.DE
|
||||
.PP
|
||||
This line is selected if type either 0 or
|
||||
.BR exit .
|
||||
The command
|
||||
.B exit
|
||||
is then executed.
|
||||
The double semicolons ``;;''
|
||||
are required to show the end of the commands for this
|
||||
.B case
|
||||
statement.
|
||||
.PP
|
||||
Each
|
||||
.B case
|
||||
statement can hold any command or series of commands that you
|
||||
could type at your terminal.
|
||||
.B esac
|
||||
at the bottom is
|
||||
.B case
|
||||
spelled backwards; it marks the end of the whole
|
||||
.B case
|
||||
statement.
|
||||
.PP
|
||||
The expression
|
||||
.B *)
|
||||
catches any pattern that does not match earlier
|
||||
patterns.
|
||||
In this case, a message is displayed.
|
||||
The pound sign `#' marks the beginning of a comment.
|
||||
.PP
|
||||
You have great power to do things as a result of
|
||||
the user selecting a choice.
|
||||
Of course, you need to match the name and number in your
|
||||
menu table with the patterns in the
|
||||
.B case
|
||||
statement;
|
||||
it is easy to edit the first part and forget to edit the second.
|
||||
.SH "See Also"
|
||||
COHERENT Lexicon:
|
||||
.B
|
||||
case,
|
||||
cat,
|
||||
clear,
|
||||
echo,
|
||||
esac,
|
||||
ksh,
|
||||
read,
|
||||
sh
|
||||
.R
|
||||
@@ -0,0 +1,33 @@
|
||||
.TH minimum "" "" "/rdb Command"
|
||||
.PC "Display the minimum of each column selected"
|
||||
\fBminimum [ \-l ] [ \fIcolumn ... \fB] < \fItable\fR
|
||||
.PP
|
||||
.II "column^minimum value"
|
||||
The command
|
||||
.B minimum
|
||||
returns the lowest value of each
|
||||
.I column
|
||||
in
|
||||
.IR table .
|
||||
If no
|
||||
column is named on the command line,
|
||||
.B minimum
|
||||
returns the minimum value for every column in
|
||||
.IR table .
|
||||
Blank lines are given the value of zero.
|
||||
.PP
|
||||
Option \fB\-l\fR returns the contents of
|
||||
.IR table ,
|
||||
as well as the minimum value of each
|
||||
.IR column .
|
||||
.SH Example
|
||||
For an example of using the command in a script, see the
|
||||
.B
|
||||
total
|
||||
.R
|
||||
.SH "See Also"
|
||||
.B
|
||||
maximum,
|
||||
mean,
|
||||
total
|
||||
.R
|
||||
+35
@@ -0,0 +1,35 @@
|
||||
.TH not "" "" "/rdb Command"
|
||||
.PC "Logical not, to reverse return status of command"
|
||||
\fBnot \fIcommand ...\fR
|
||||
.PP
|
||||
.II "return value^invert"
|
||||
.II "logical NOT"
|
||||
The command
|
||||
.B not
|
||||
converts a return status of zero to 255, and any nonzero
|
||||
return status to zero.
|
||||
Thus, true becomes false and vice versa.
|
||||
This is used to test a command for not true or false.
|
||||
.SH Example
|
||||
This example shows how
|
||||
.B not
|
||||
reverses the return code of the COHERENT command
|
||||
.BR true :
|
||||
.DM
|
||||
true ; echo $?
|
||||
.DE
|
||||
.PP
|
||||
This command returns zero.
|
||||
On the other hand, the command
|
||||
.DM
|
||||
not true ; echo $?
|
||||
.DE
|
||||
.PP
|
||||
returns 255.
|
||||
.SH "See Also"
|
||||
COHERENT Lexicon:
|
||||
.B
|
||||
false,
|
||||
true
|
||||
.R
|
||||
.SO not
|
||||
@@ -0,0 +1,27 @@
|
||||
.TH Number "" "" "/rdb Command"
|
||||
.PC "Insert a column-row number into a table or list"
|
||||
\fBNumber < \fItableorlist\fR
|
||||
.PP
|
||||
.B Number
|
||||
creates appends a new column to the beginning of a table,
|
||||
or as the first field in a list.
|
||||
The newly created column contains the number of each row in the table.
|
||||
Unlike the related command
|
||||
.BR number ,
|
||||
.B Number
|
||||
capitalizes
|
||||
the column heading \(em that is,
|
||||
the name of the command sets the name of the column.
|
||||
.SH "See Also"
|
||||
.B
|
||||
number
|
||||
.R
|
||||
.SH Notes
|
||||
To change the name of a column, use the command
|
||||
.BR rename .
|
||||
To move the row-number column to a different position within its table,
|
||||
use the command
|
||||
.BR column .
|
||||
If you want to change the name of the number column
|
||||
to something else, use the command
|
||||
.BR rename .
|
||||
@@ -0,0 +1,70 @@
|
||||
.TH number "" "" "/rdb Command"
|
||||
.PC "Insert a column-row number into a table or list"
|
||||
\fBNumber < \fItableorlist\fR
|
||||
.PP
|
||||
.II "column^append row number"
|
||||
.II "row^number column"
|
||||
.II "append row-number column"
|
||||
.II "table^append row-number column"
|
||||
The command
|
||||
.B number
|
||||
creates appends a new column to the beginning of a table,
|
||||
or as the first field in a list.
|
||||
The newly created column contains the number of each row in the table.
|
||||
Unlike the related command
|
||||
.BR Number ,
|
||||
.B number
|
||||
writes the word ``number'' in lower-case letters as the header on the
|
||||
column.
|
||||
.SH Example
|
||||
For example, consider the following table, called
|
||||
.BR inventory :
|
||||
.DM
|
||||
Item# Amount Cost Value Description
|
||||
------- ------- ------- ------- ---------------
|
||||
1 3 5.00 15.00 rubber gloves
|
||||
2 100 0.50 50.00 test tubes
|
||||
3 5 8.00 40.00 clamps
|
||||
4 23 1.98 45.54 plates
|
||||
5 99 2.45 242.55 cleaning cloth
|
||||
6 89 14.75 1312.75 bunsen burners
|
||||
7 5 175.00 875.00 scales
|
||||
.DE
|
||||
.PP
|
||||
Typing the command
|
||||
.DM
|
||||
number < inventory
|
||||
.DE
|
||||
.PP
|
||||
yields the following result:
|
||||
.DM
|
||||
number Item# Amount Cost Value Description
|
||||
------- ------- ------- ------- ------- ---------------
|
||||
1 1 3 5.00 15.00 rubber gloves
|
||||
2 2 100 0.50 50.00 test tubes
|
||||
3 3 5 8.00 40.00 clamps
|
||||
4 4 23 1.98 45.54 plates
|
||||
5 5 99 2.45 242.55 cleaning cloth
|
||||
6 6 89 14.75 1312.75 bunsen burners
|
||||
7 7 5 175.00 875.00 scales
|
||||
.DE
|
||||
.PP
|
||||
Note that the first column is the new number column.
|
||||
.PP
|
||||
.SH "See Also"
|
||||
.B
|
||||
Number,
|
||||
addcol,
|
||||
column,
|
||||
jointable,
|
||||
rename
|
||||
.R
|
||||
.SH Notes
|
||||
To change the name of a column, use the command
|
||||
.BR rename .
|
||||
To move the row-number column to a different position within its table,
|
||||
use the command
|
||||
.BR column .
|
||||
If you want to change the name of the number column
|
||||
to something else, use the command
|
||||
.BR rename .
|
||||
+103
@@ -0,0 +1,103 @@
|
||||
.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
|
||||
@@ -0,0 +1,116 @@
|
||||
.TH padstring "" "" "/rdb Command"
|
||||
.PC "Return string with blanks to fill a field"
|
||||
\fBpadstring [-]\fIlength string\fR
|
||||
.PP
|
||||
.II "string^pad with spaces"
|
||||
The command
|
||||
.B padstring
|
||||
adds blanks to the end of
|
||||
.I string
|
||||
to make it the requested
|
||||
.IR length .
|
||||
This command useful for screen and report writing,
|
||||
where you want to line up everything.
|
||||
.PP
|
||||
The option
|
||||
.I -length
|
||||
means to left-justify the string in the field, that is,
|
||||
write the padding blanks to the end of
|
||||
.IR string .
|
||||
The option
|
||||
.IR length ,
|
||||
without the hyphen,
|
||||
right justifies the string \(em that is, it adds the spaces to the
|
||||
beginning of
|
||||
.IR string .
|
||||
.SH Example
|
||||
The first example
|
||||
.DM
|
||||
padstring 10 string
|
||||
.DE
|
||||
.PP
|
||||
displays the string:
|
||||
.DM
|
||||
string
|
||||
.DE
|
||||
.PP
|
||||
Note that the string is right-justified; that is, the spaces were added to
|
||||
the left of
|
||||
.BR string .
|
||||
.PP
|
||||
Now we can use this in a
|
||||
.B report
|
||||
form file to make fixed-length fields.
|
||||
An ordinary form has the files to the right of a field, moving all around.
|
||||
For example, the command
|
||||
.DM
|
||||
report form < mailtable
|
||||
.DE
|
||||
.PP
|
||||
writes the output:
|
||||
.DM
|
||||
Name : Ronald McDonald Company: McDonald's
|
||||
Street: 123 Mac Attack
|
||||
City : Menphis State : TENN ZIP: 30000
|
||||
Phone : (111) 222-3333
|
||||
.sp \n(pDu
|
||||
Name : Chiquita Banana Company: United Brands
|
||||
Street: Uno Avenito De La Revolution
|
||||
City : San Jose State : Costa Rica ZIP: 123456789
|
||||
Phone : 1234
|
||||
.DE
|
||||
.PP
|
||||
This result is rather messy.
|
||||
However, if we edit the file
|
||||
.B form
|
||||
to include the
|
||||
.B padstring
|
||||
command, then we will get a fixed form, as follows:
|
||||
.DM
|
||||
Name : <!padstring -17 '<Name>'!> Company: <Company>
|
||||
Street: <Street>
|
||||
City : <!padstring -17 '<City>'!> State : <State> ZIP: <ZIP>
|
||||
Phone : <Phone>
|
||||
.DE
|
||||
.PP
|
||||
Now, running
|
||||
.B report
|
||||
on this file yields:
|
||||
.DM
|
||||
Name : Ronald McDonald Company: McDonald's
|
||||
Street: 123 Mac Attack
|
||||
City : Menphis State : TENN ZIP: 30000
|
||||
Phone : (111) 222-3333
|
||||
.sp \n(pDu
|
||||
Name : Chiquita Banana Company: United Brands
|
||||
Street: Uno Avenito De La Revolution
|
||||
City : San Jose State : Costa Rica ZIP: 123456789
|
||||
Phone : 1234
|
||||
.DE
|
||||
.PP
|
||||
Note that
|
||||
.B State
|
||||
has not been done yet, and therefore
|
||||
.B ZIP
|
||||
moves back and forth;
|
||||
but
|
||||
.B Company
|
||||
and
|
||||
.B State
|
||||
stay lined up correctly.
|
||||
.PP
|
||||
Note that if
|
||||
.B padstring
|
||||
is too long a name, use the COHERENT link command
|
||||
.B ln
|
||||
to link it to a shorter name.
|
||||
.SH "See Also"
|
||||
.B
|
||||
report,
|
||||
screen
|
||||
.R
|
||||
.br
|
||||
COHERENT Lexicon:
|
||||
.B
|
||||
ln
|
||||
.R
|
||||
@@ -0,0 +1,137 @@
|
||||
.TH paste.rdb "" "" "/rdb Command"
|
||||
.PC "Paste together two or more tables"
|
||||
\fBpaste.rdb \fItable1 table2 ...\fR
|
||||
.PP
|
||||
.II "table^paste"
|
||||
.II "paste tables"
|
||||
The command
|
||||
.B paste.rdb
|
||||
displays
|
||||
.IR table1 ,
|
||||
.IR table2 ,
|
||||
and so on, side by side.
|
||||
This is almost identical to the COHERENT command
|
||||
.BR paste .
|
||||
.PP
|
||||
The
|
||||
.B /rdb
|
||||
version of
|
||||
.B paste.rdb
|
||||
uses the COHERENT
|
||||
command
|
||||
.B pr
|
||||
to list the tables side by side:
|
||||
.DM
|
||||
pr -m -t -s table1 table2 [...]
|
||||
.DE
|
||||
.PP
|
||||
.B paste.rdb
|
||||
differs from the command
|
||||
.B jointable
|
||||
in that
|
||||
.B jointable
|
||||
looks for matching values in key columns and writes only the
|
||||
rows in which it finds a match.
|
||||
.BR paste.rdb
|
||||
does not care what it is pasting together.
|
||||
You can get some interesting garbage with
|
||||
.BR paste.rdb .
|
||||
.PP
|
||||
You can also do a kind of visual
|
||||
.B diff
|
||||
in which you can see an old and new file lined up side by side.
|
||||
You could do this with two list files, but be careful, because
|
||||
the output will generally not be acceptable by other
|
||||
.B /rdb
|
||||
programs.
|
||||
.SH Example
|
||||
The following commands break the table
|
||||
.BR inventory :
|
||||
.DM
|
||||
column Item Value < inventory > tmp1
|
||||
column Cost Amount Description < inventory > tmp2
|
||||
.DE
|
||||
.PP
|
||||
This yields table
|
||||
.BR tmp1
|
||||
.DM
|
||||
Item Value
|
||||
----- -----
|
||||
1 150
|
||||
2 500
|
||||
3 400
|
||||
4 437
|
||||
5 2376
|
||||
6 13083
|
||||
7 875
|
||||
.DE
|
||||
.PP
|
||||
.BR tmp2 :
|
||||
.DM
|
||||
Cost Amount Description
|
||||
---- ------ --------------
|
||||
50 3 rubber gloves
|
||||
5 100 test tubes
|
||||
80 5 clamps
|
||||
19 23 plates
|
||||
24 99 cleaning cloth
|
||||
147 89 bunsen burners
|
||||
175 5 scales
|
||||
.DE
|
||||
.PP
|
||||
Now, you can use
|
||||
.B paste.rdb
|
||||
to put them back together:
|
||||
.DM
|
||||
paste.rdb tmp1 tmp2
|
||||
.DE
|
||||
.PP
|
||||
This writes the following onto the standard output:
|
||||
.DM
|
||||
Item Value Cost Amount Description
|
||||
----- ----- ---- ------ --------------
|
||||
1 150 50 3 rubber gloves
|
||||
2 500 5 100 test tubes
|
||||
3 400 80 5 clamps
|
||||
4 437 19 23 plates
|
||||
5 2376 24 99 cleaning cloth
|
||||
6 13083 147 89 bunsen burners
|
||||
7 875 175 5 scales
|
||||
.DE
|
||||
.PP
|
||||
This is not an efficient way use
|
||||
.BR column ;
|
||||
one command could do the job, instead of two.
|
||||
.BR paste.rdb ,
|
||||
however, it is a good way to put tables together if
|
||||
.B jointable
|
||||
is inappropriate.
|
||||
If you had wanted to use
|
||||
.B jointable
|
||||
here, you should
|
||||
.B project
|
||||
column
|
||||
.B Item
|
||||
into both tables.
|
||||
.SH "See Also"
|
||||
.B
|
||||
column,
|
||||
jointable
|
||||
.R
|
||||
.br
|
||||
COHERENT Lexicon:
|
||||
.B
|
||||
diff,
|
||||
paste,
|
||||
pr
|
||||
.R
|
||||
.SH Notes
|
||||
This command is named
|
||||
.B paste.rdb
|
||||
rather than
|
||||
.BR paste ,
|
||||
as in other implementations of
|
||||
.BR /rdb ,
|
||||
to avoid clashing with the COHERENT command
|
||||
.BR paste .
|
||||
.SO paste
|
||||
@@ -0,0 +1,80 @@
|
||||
.TH path "" "" "/rdb Command"
|
||||
.PC "Find the full path of a command"
|
||||
\fBpath [ \fIcommand ... \fB]\fR
|
||||
.PP
|
||||
.II "command^find path"
|
||||
The command
|
||||
.B path
|
||||
finds the directory path to a command, if it is in one of the
|
||||
directories in your shell's
|
||||
.B PATH
|
||||
environment variable.
|
||||
.PP
|
||||
A path means two things in COHERENT:
|
||||
.IP \fB1.\fR 0.3i
|
||||
It means the list of nested directories within which a file is located.
|
||||
For example, file
|
||||
.B FOO
|
||||
may have the path of
|
||||
.BR /usr/local/src/ ;
|
||||
this means that FOO
|
||||
is kept in directory
|
||||
.BR src ,
|
||||
which in turn is in directory
|
||||
.BR local ,
|
||||
which in turn is in directory
|
||||
.BR usr ,
|
||||
which in turn is in directory
|
||||
.BR / .
|
||||
.IP \fB2.\fR
|
||||
It means a list of directories that the shell searches
|
||||
to find an executable program that matches the command typed in.
|
||||
Each user has his path stored in the environmental variable
|
||||
.BR PATH ;
|
||||
to see your path, type the command:
|
||||
.DM
|
||||
echo $PATH
|
||||
.DE
|
||||
.PP
|
||||
.B path
|
||||
searches the directories named in your
|
||||
.B PATH
|
||||
to find the path of
|
||||
.IR command .
|
||||
If
|
||||
.B path
|
||||
cannot find
|
||||
.I command
|
||||
or if
|
||||
.I command
|
||||
is not executable, it returns nothing.
|
||||
.SH Example
|
||||
If you type:
|
||||
.DM
|
||||
path column
|
||||
.DE
|
||||
.PP
|
||||
If this command returns
|
||||
.DM
|
||||
/usr/rdb/bin
|
||||
.DE
|
||||
.PP
|
||||
then
|
||||
.B column
|
||||
lives in directory:
|
||||
.BR /usr/rdb/bin .
|
||||
.PP
|
||||
Please note that for
|
||||
.B path
|
||||
to work, you must insert into your
|
||||
.B PATH
|
||||
the directory that holds the
|
||||
.B /rdb
|
||||
commands.
|
||||
.SH "See Also"
|
||||
COHERENT Lexicon:
|
||||
.B
|
||||
PATH,
|
||||
\&.profile
|
||||
.R
|
||||
.SO path
|
||||
@@ -0,0 +1,29 @@
|
||||
.TH precision "" "" "/rdb Command"
|
||||
.PC "Display the precision of a column"
|
||||
\fBprecision [ \-l ] [ \fIcolumn ...\fB ] < \fItable\fR
|
||||
.PP
|
||||
.II "column^find precision"
|
||||
The command
|
||||
.B precision
|
||||
returns the maximum number of digits to the right of the
|
||||
decimal point in each
|
||||
.IR column .
|
||||
If no
|
||||
.I column
|
||||
is named on the command line,
|
||||
.B precision
|
||||
returns information on every numeric column in
|
||||
.IR table .
|
||||
.PP
|
||||
The option
|
||||
.B \-l
|
||||
tells
|
||||
.B precision
|
||||
to return the entire
|
||||
.IR table ,
|
||||
in addition to the precision of each
|
||||
.IR column .
|
||||
.SH Example
|
||||
For example of this command, see the entry for
|
||||
.BR total .
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
.TH project "" "" "/rdb Command"
|
||||
.PC "Write selected projects (same as column)"
|
||||
\fBproject [ \fIcolumn ...\fB ] < \fItableorlist\fR
|
||||
.PP
|
||||
The command
|
||||
.B project
|
||||
is another name for the command
|
||||
.BR column .
|
||||
.SH "See Also"
|
||||
.B
|
||||
column
|
||||
.R
|
||||
@@ -0,0 +1,60 @@
|
||||
.TH prompt "" "" "/rdb Command"
|
||||
.PC "Echo a string on the standard output"
|
||||
\fBprompt \fIstring ...\fR
|
||||
.PP
|
||||
.II "string^prompt"
|
||||
.II echo
|
||||
The command
|
||||
.B prompt
|
||||
echoes a string onto the standard output.
|
||||
It resembles the COHERENT command
|
||||
.BR echo ,
|
||||
but it does not write a newline character after the echoed string.
|
||||
Thus, you can use
|
||||
.B prompt
|
||||
to write a prompt onto the screen.
|
||||
.SH Example
|
||||
The command
|
||||
.DM
|
||||
prompt "Please enter your name: "
|
||||
.DE
|
||||
.PP
|
||||
writes the following on the standard output:
|
||||
.DM
|
||||
Please enter your name: _
|
||||
.DE
|
||||
.PP
|
||||
The underscore character marks where this command leaves the cursor.
|
||||
.SH "See Also"
|
||||
.B
|
||||
chr
|
||||
.R
|
||||
.br
|
||||
COHERENT Lexicon:
|
||||
.B
|
||||
echo
|
||||
.R
|
||||
.SH Notes
|
||||
.B prompt
|
||||
looks for an environmental variable called
|
||||
.BR ECHONOCR .
|
||||
If the variable is missing or not equal to
|
||||
.BR \-n ,
|
||||
then
|
||||
.B prompt
|
||||
calles the COHERENT command
|
||||
.B echo
|
||||
with its \fB\-n\fR option, which drops the newline.
|
||||
If
|
||||
.B ECHONOCR
|
||||
is set to anything other than
|
||||
.BR \-n ,
|
||||
then
|
||||
.B prompt
|
||||
calls
|
||||
.BR \ec
|
||||
option, which is used by some UNIX systems.
|
||||
When using
|
||||
.BR /rdb
|
||||
under the COHERENT system, it is best just to not set
|
||||
.BR ECHONOCR .
|
||||
+20
@@ -0,0 +1,20 @@
|
||||
.TH rdb "" "" "/rdb Command"
|
||||
.PC "List all /rdb programs in directory $RDB/bin"
|
||||
.B rdb
|
||||
.PP
|
||||
.II "command^list all"
|
||||
.II "list all commands"
|
||||
The command
|
||||
.B rdb
|
||||
prints on the standard output all commands in directory
|
||||
.BR $RDB/bin .
|
||||
This command is a shell script, which you should edit if its output
|
||||
is not to your liking.
|
||||
.SH "See Also"
|
||||
.B
|
||||
act,
|
||||
helpme,
|
||||
whatis,
|
||||
whatwill
|
||||
.R
|
||||
.SO rdb
|
||||
@@ -0,0 +1,27 @@
|
||||
.\" Macros used by the MWC /rdb man pages that groff's man package lacks.
|
||||
.de DM
|
||||
.sp 0.5
|
||||
.nf
|
||||
.in +4n
|
||||
..
|
||||
.de DS
|
||||
.DM
|
||||
..
|
||||
.de DE
|
||||
.in -4n
|
||||
.fi
|
||||
.sp 0.5
|
||||
..
|
||||
.de PC
|
||||
.\" short description, already shown by .TH
|
||||
..
|
||||
.de II
|
||||
..
|
||||
.de SO
|
||||
..
|
||||
.de B1
|
||||
.DM
|
||||
..
|
||||
.de B2
|
||||
.DE
|
||||
..
|
||||
@@ -0,0 +1,72 @@
|
||||
.TH record "" "" "/rdb Command"
|
||||
.PC "Find and output a record from a table"
|
||||
\fBrecord \fInumber \fB< \fItable\fR
|
||||
.PP
|
||||
.II "row^find r. by number"
|
||||
.II "find record by number"
|
||||
The command
|
||||
.B record
|
||||
searches through
|
||||
.I table
|
||||
for the record with the serial number
|
||||
.IR number .
|
||||
If it finds the record, it prints it and the table's header on the
|
||||
standard output.
|
||||
.SH Example
|
||||
To retrieve the third record from table
|
||||
.BR inventory ,
|
||||
type:
|
||||
.DM
|
||||
record 3 < inventory
|
||||
.DE
|
||||
.PP
|
||||
You will see something like the following:
|
||||
.DM
|
||||
Item Amount Cost Value Description
|
||||
---- ------ ---- ----- --------------
|
||||
3 5 80 400 clamps
|
||||
.DE
|
||||
.PP
|
||||
The following shell script uses
|
||||
.B record
|
||||
and
|
||||
.B read
|
||||
to find specific values in table
|
||||
.BR inventory .
|
||||
The command
|
||||
.B read
|
||||
uses the head line of
|
||||
.B inventory
|
||||
to assign values to each column name.
|
||||
.DM
|
||||
: describe - gives the description for an item in inventory
|
||||
USAGE='usage: describe Item < table'
|
||||
.sp \n(pDu
|
||||
record $1 < inventory |
|
||||
( read HEAD
|
||||
read DASH
|
||||
read $HEAD
|
||||
echo "Item $Item is $Description"
|
||||
)
|
||||
.DE
|
||||
.PP
|
||||
When you type
|
||||
.DM
|
||||
describe 1 < inventory
|
||||
.DE
|
||||
.PP
|
||||
you see output in the following format:
|
||||
.DM
|
||||
Item 1 is rubber gloves
|
||||
.DE
|
||||
.SH "See Also"
|
||||
.B
|
||||
row,
|
||||
search
|
||||
.R
|
||||
.br
|
||||
COHERENT Lexicon:
|
||||
.B
|
||||
read
|
||||
.R
|
||||
.SO record
|
||||
+118
@@ -0,0 +1,118 @@
|
||||
.TH rename "" "" "/rdb Command"
|
||||
.PC "Rename a column"
|
||||
\fBrename [ \fIoldcolumn newcolumn ...\fB ] < \fItableorlist\fR
|
||||
.PP
|
||||
.II column^rename
|
||||
The command
|
||||
.B rename
|
||||
changes the name of
|
||||
.I oldcolumn
|
||||
to
|
||||
.I newcolumn
|
||||
within
|
||||
.IR tableorlist .
|
||||
You can name on the command line
|
||||
as many \fIoldcolumn/newcolumn\fR pairs as you wish.
|
||||
.SH Example
|
||||
Consider the table
|
||||
.BR inventory :
|
||||
.DM
|
||||
Item# Amount Cost Value Description
|
||||
----- ------ ----- ------- --------------
|
||||
1 3 5.00 15.00 rubber gloves
|
||||
2 100 0.50 50.00 test tubes
|
||||
3 5 8.00 40.00 clamps
|
||||
4 23 1.98 45.54 plates
|
||||
5 99 2.45 242.55 cleaning cloth
|
||||
6 89 14.75 1312.75 bunsen burners
|
||||
7 5 175.00 875.00 scales
|
||||
.DE
|
||||
.PP
|
||||
The command
|
||||
.DM
|
||||
rename Amount Qty Description Name < inventory
|
||||
.DE
|
||||
.PP
|
||||
renames
|
||||
.B Amount
|
||||
to
|
||||
.BR Qty ,
|
||||
and
|
||||
.B Description
|
||||
to
|
||||
.BR Name .
|
||||
The table now appears as follows:
|
||||
.DM
|
||||
Item# Qty Cost Value Name
|
||||
----- --- ------ ------- --------------
|
||||
1 3 5.00 15.00 rubber gloves
|
||||
2 100 0.50 50.00 test tubes
|
||||
3 5 8.00 40.00 clamps
|
||||
4 23 1.98 45.54 plates
|
||||
5 99 2.45 242.55 cleaning cloth
|
||||
6 89 14.75 1312.75 bunsen burners
|
||||
7 5 175.00 875.00 scales
|
||||
.DE
|
||||
.PP
|
||||
If you have a list-formatted file, you can also rename the column names.
|
||||
For example, consider the list
|
||||
.BR maillist :
|
||||
.DM
|
||||
Number 1
|
||||
Name Ronald McDonald
|
||||
Company McDonald's
|
||||
Street 123 Mac Attack
|
||||
City Memphis
|
||||
State TENN
|
||||
ZIP 30000
|
||||
Phone (111) 222-3333
|
||||
.DE
|
||||
.DM
|
||||
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
|
||||
The command
|
||||
.DM
|
||||
rename Number Num ZIP Zip < maillist
|
||||
.DE
|
||||
.PP
|
||||
changes
|
||||
.B Number
|
||||
to
|
||||
.BR Num ,
|
||||
and
|
||||
.B ZIP
|
||||
to
|
||||
.BR Zip .
|
||||
The list now appears as follows:
|
||||
.DM
|
||||
Num 1
|
||||
Name Ronald McDonald
|
||||
Company McDonald's
|
||||
Street 123 Mac Attack
|
||||
City Memphis
|
||||
State TENN
|
||||
Zip 30000
|
||||
Phone (111) 222-3333
|
||||
.DE
|
||||
.DM
|
||||
Num 2
|
||||
Name Chiquita Banana
|
||||
Company United Brands
|
||||
Street Uno Avenido de la Reforma
|
||||
City San Jose
|
||||
State Costa Rica
|
||||
Zip 123456789
|
||||
Phone 1234
|
||||
.DE
|
||||
.SH "See Also"
|
||||
.B
|
||||
column
|
||||
.R
|
||||
+154
@@ -0,0 +1,154 @@
|
||||
.TH replace "" "" "/rdb Command"
|
||||
.PC "Insert a record into a file at specified location"
|
||||
\fBreplace [\-a] [\-m[bhirs] \fItableorlist from to \fB[\fIxfrom xto\fB] < \fIintableorlist\fR
|
||||
.PP
|
||||
.II row^replace
|
||||
The command
|
||||
.B replace
|
||||
replaces the row at offsets
|
||||
.I from
|
||||
through
|
||||
.I to
|
||||
in
|
||||
.I tableorlist
|
||||
with the contents of
|
||||
.IR intableorlist .
|
||||
.B replace
|
||||
will not insert a record larger than
|
||||
.I to
|
||||
minus
|
||||
.IR from .
|
||||
It adds spaces to the
|
||||
.I last
|
||||
column of records within
|
||||
.I tableorlist
|
||||
that are smaller than the input record.
|
||||
.PP
|
||||
.I xfrom
|
||||
and
|
||||
.I xto
|
||||
give the beginning and end of the offsets of the index entry within
|
||||
.IR tableorlist 's
|
||||
associated fast-access table, should there be one.
|
||||
.PP
|
||||
To obtain painlessly the offsets of the record and its index entry, use
|
||||
the command
|
||||
.BR seek .
|
||||
This is demonstrated in the following example.
|
||||
.PP
|
||||
The command
|
||||
.B update
|
||||
remembers the location and size of the record it takes out of a file
|
||||
and passes it to
|
||||
.B replace
|
||||
so that only a correctly sized file goes back into that file.
|
||||
.SH Options
|
||||
.B replace
|
||||
recognizes the following options:
|
||||
.IP \fB\-a\fR
|
||||
Do not append the record in
|
||||
.I intableorlist
|
||||
to the end of
|
||||
.IR tableorlist .
|
||||
The default to append if the record is too big
|
||||
to fit back into the location from which it was taken.
|
||||
This option allows you to prevent appending.
|
||||
If you want a binary file to stay
|
||||
sorted, you will either have to resort it or not allow appending.
|
||||
.IP \fB\-m[bhirs]\fR
|
||||
Fast access methods.
|
||||
See the manual page for
|
||||
.B index
|
||||
for a description of what each of these options means.
|
||||
.SH Example
|
||||
If table
|
||||
.B recordtable
|
||||
contains one record, you use can insert that record into table
|
||||
.B bigfile
|
||||
with the following command:
|
||||
.DM
|
||||
replace bigfile 1421 1487 0 8 < recordtable
|
||||
.DE
|
||||
.PP
|
||||
Note that the contents of
|
||||
.B recordtable
|
||||
replace rows 1421 through 1487 within
|
||||
.BR bigfile .
|
||||
.PP
|
||||
For the second example, consider again table
|
||||
.BR inventory ,
|
||||
as follows:
|
||||
.DM
|
||||
Item Amount Cost Value Description
|
||||
---- ------ ---- ----- --------------
|
||||
1 3 50 150 rubber gloves
|
||||
2 100 5 500 test tubes
|
||||
3 5 80 400 clamps
|
||||
4 23 19 437 plates
|
||||
5 99 24 2376 cleaning cloth
|
||||
6 89 147 13083 bunsen burners
|
||||
7 5 175 875 scales
|
||||
.DE
|
||||
.PP
|
||||
First, let's use the command
|
||||
.B seek
|
||||
to extract a record, and save its offset in the shell variable
|
||||
.BR LOCATION :
|
||||
.DM
|
||||
LOCATION=`echo 5 | seek -mr -o tmpfile inventory Item`
|
||||
.DE
|
||||
.PP
|
||||
.B $LOCATION
|
||||
is initialized to the following
|
||||
.DM
|
||||
207 245 54 62
|
||||
.DE
|
||||
.PP
|
||||
and
|
||||
.B tmpfile
|
||||
contains the following:
|
||||
.DM
|
||||
Item Amount Cost Value Description
|
||||
---- ------ ---- ----- --------------
|
||||
5 99 24 2376 cleaning cloth
|
||||
.DE
|
||||
.PP
|
||||
Here we use the record fast-access method.
|
||||
.PP
|
||||
Now let's
|
||||
change 99 to 199 within
|
||||
.BR tmpfile ,
|
||||
so we can see a change:
|
||||
.DM
|
||||
Item Amount Cost Value Description
|
||||
---- ------ ---- ----- --------------
|
||||
5 199 24 2376 cleaning cloth
|
||||
.DE
|
||||
.PP
|
||||
Now we can replace the edited record in
|
||||
.BR inventory :
|
||||
.DM
|
||||
replace -mr inventory $LOCATION < tmpfile
|
||||
.DE
|
||||
.PP
|
||||
.B inventory
|
||||
now appears as follows:
|
||||
.DM
|
||||
Item Amount Cost Value Description
|
||||
---- ------ ---- ----- --------------
|
||||
1 3 50 150 rubber gloves
|
||||
2 100 5 500 test tubes
|
||||
3 5 80 400 clamps
|
||||
4 23 19 437 plates
|
||||
5 199 24 2376 cleaning cloth
|
||||
6 89 147 13083 bunsen burners
|
||||
7 5 175 875 scales
|
||||
.DE
|
||||
.PP
|
||||
You can see that row 5 has been updated, because it now has
|
||||
199 in it.
|
||||
.SH "See Also"
|
||||
.B
|
||||
seek,
|
||||
update
|
||||
.R
|
||||
+187
@@ -0,0 +1,187 @@
|
||||
.TH report "" "" "/rdb Command"
|
||||
.PC "Write reports using a form and a table"
|
||||
\fBreport \fIform \fB< \fItableorlist\fR
|
||||
.PP
|
||||
The command
|
||||
.B report
|
||||
produces reports, form letters, mailing labels, invoices,
|
||||
and so forth, for each row in
|
||||
.IR tableorlist ,
|
||||
following the template within file
|
||||
.IR form .
|
||||
.PP
|
||||
You must use a text editor to fill out
|
||||
.I form
|
||||
to determine how the form will appear.
|
||||
Insert column names from
|
||||
.I tableorlist
|
||||
between angle brackets (< >)
|
||||
where you want the data to appear within the report.
|
||||
.PP
|
||||
You can even call shell commands from within a form,
|
||||
pass them data from
|
||||
.IR tableorlist ,
|
||||
print their output within your formatted form.
|
||||
This is a powerful extension to COHERENT shell programming.
|
||||
.PP
|
||||
.B report
|
||||
mostly replaces the older commands
|
||||
.B label
|
||||
and
|
||||
.BR letter .
|
||||
These commands are still part of
|
||||
.BR /rdb ,
|
||||
in part for compatibility with older versions, and in part as examples
|
||||
of shell programming.
|
||||
.SH "Form Syntax"
|
||||
The following describes the format of a form:
|
||||
.IP "\fIregular text\fR"
|
||||
.B form
|
||||
prints any characters in your form that do not match the symbols
|
||||
shown below.
|
||||
.IP "\fI<column-name>\fR"
|
||||
Angle brackets indicate that data from
|
||||
.I "column-name"
|
||||
in the current row of
|
||||
.I tableorlist
|
||||
should be inserted in place of the column name.
|
||||
.IP "\fI<!command!>\fR"
|
||||
Angle brackets and exclamation points indicate that the shell is to execute
|
||||
.IR command .
|
||||
Any output from
|
||||
.I command
|
||||
appears at this point in the report.
|
||||
.IP "\fI<!cmd <col>!>\fR"
|
||||
This is an insertion within a command.
|
||||
The data from column
|
||||
.I col
|
||||
in the current row of
|
||||
.I tableorlist
|
||||
are passed to
|
||||
.IR cmd .
|
||||
This passes the contents of
|
||||
.I col
|
||||
as an argument to
|
||||
.IR command .
|
||||
The output of
|
||||
.I command
|
||||
then replaces this entry within the form.
|
||||
.PP
|
||||
If
|
||||
.B report
|
||||
does not recognize a column name, it prints
|
||||
.I "<column-name>"
|
||||
as if it were normal text.
|
||||
This allows you to use the angle brackets as literal characters within your
|
||||
form, if you wish.
|
||||
It also helps you debug your form:
|
||||
if the data from the table are not replacing
|
||||
.IR "<column-name>" ,
|
||||
then
|
||||
.I "column-name"
|
||||
does not exactly match the column name in the table.
|
||||
Check for spelling errors, upper- and lower-case discrepancies,
|
||||
embedded blanks, and nonprinting characters.
|
||||
.SH Example
|
||||
Consider table
|
||||
.BR maillist ,
|
||||
as follows:
|
||||
.DM
|
||||
Name Ronald McDonald
|
||||
Company McDonald's
|
||||
Street 123 Mac Attack
|
||||
City Memphis
|
||||
State TENN
|
||||
ZIP 30000
|
||||
Phone (111) 222-3333
|
||||
.DE
|
||||
.DM
|
||||
Name Chiquita Banana
|
||||
Company United Brands
|
||||
Street Uno Avenido de la Reforma
|
||||
City San Jose
|
||||
State Costa Rica
|
||||
ZIP 123456789
|
||||
Phone 1234
|
||||
.DE
|
||||
.PP
|
||||
You could use an editor to develop a form like the following:
|
||||
.DM
|
||||
<Name>
|
||||
<Company>
|
||||
<Street>
|
||||
< City >, <State> <ZIP>
|
||||
.DE
|
||||
.DM
|
||||
Hi < Name >:
|
||||
.sp \n(pDu
|
||||
The date and time is <!date!>
|
||||
.sp \n(pDu
|
||||
We are also sending this letter to:
|
||||
.sp \n(pDu
|
||||
<! column Name City < mailtable | row 'Name != "<Name>"' | justify !>
|
||||
Bye <! echo <Name> !>
|
||||
.DE
|
||||
.PP
|
||||
Note that we have used all three types of inserts:
|
||||
column name, command, and command insert.
|
||||
Now with these two files ready, you only need type
|
||||
.DM
|
||||
report form < maillist
|
||||
.DE
|
||||
.PP
|
||||
to see the following output:
|
||||
.B1
|
||||
Ronald McDonald
|
||||
McDonald's
|
||||
123 Mac Attack
|
||||
Memphis, TENN 30000
|
||||
.sp
|
||||
Hi Ronald McDonald:
|
||||
.sp \n(pDu
|
||||
The date and time is Wed Aug 19 01:58:19 PST 1983
|
||||
.sp \n(pDu
|
||||
We are also sending this letter to:
|
||||
.sp
|
||||
Name City
|
||||
--------------- -------
|
||||
Chiquita Banana San Jose
|
||||
.sp \n(pDu
|
||||
Bye Ronald McDonald
|
||||
.B2
|
||||
.PP
|
||||
.B1
|
||||
Chiquita Banana
|
||||
United Brands
|
||||
Uno Avenido de la Reforma
|
||||
San Jose, Costa Rica 123456789
|
||||
.sp \n(pDu
|
||||
Hi Chiquita Banana:
|
||||
.sp \n(pDu
|
||||
The date and time is Wed Aug 19 01:58:40 PST 1983
|
||||
.sp \n(pDu
|
||||
We are also sending this letter to:
|
||||
.sp \n(pDu
|
||||
Name City
|
||||
--------------- -------
|
||||
Ronald McDonald Memphis
|
||||
.sp \n(pDu
|
||||
Bye Chiquita Banana
|
||||
.B2
|
||||
.PP
|
||||
Some users have noted that the shell escape places an
|
||||
extra line in the output.
|
||||
If you don't want the extra line say something like:
|
||||
.DM
|
||||
<! echo -n `date` !>
|
||||
.DE
|
||||
.SH "See Also"
|
||||
.B
|
||||
label,
|
||||
letter
|
||||
.R
|
||||
.br
|
||||
COHERENT Lexicon:
|
||||
.B
|
||||
echo
|
||||
.R
|
||||
@@ -0,0 +1,47 @@
|
||||
.TH reportwriter "" "" "/rdb Command"
|
||||
.PC "Sample program to write standard reports"
|
||||
.B reportwriter
|
||||
.PP
|
||||
The command
|
||||
.B reportwriter
|
||||
is a sample shell program that writes a sample standard report.
|
||||
It uses the command
|
||||
.B splittable
|
||||
to divide a table into page-sized tables.
|
||||
It shows several tricks for using COHERENT shell programming and
|
||||
.B /rdb
|
||||
tools to put together reports.
|
||||
.SH Example
|
||||
Here is what
|
||||
.B reportwriter
|
||||
produces (with the middle of each page
|
||||
replaced with an ellipsis to keep the listing short):
|
||||
.B1
|
||||
Prices of Computers that ran UNIX(TM) in 1983
|
||||
From Urban Software of New York City
|
||||
Report Date: 9 Feb 1985
|
||||
.sp
|
||||
Price Company City
|
||||
----- ------- ----
|
||||
Advanced Micro Devices Santa Clara
|
||||
Alcyon Corporation San Diego
|
||||
American Telephone & Telegraph
|
||||
BASIS Microcomputer GmbH D-4400 Muenster
|
||||
Corvus Systems San Jose
|
||||
David Computers Inc. Kitchener
|
||||
Digital Computers Ltd. Tokyo 102
|
||||
Heurikon Corp. Madison
|
||||
...
|
||||
Western Digital Irvine
|
||||
Western Electric Corp.
|
||||
4.2 Venturcom/IBM PC Cambridge
|
||||
...
|
||||
13.9 Victory Computer Systems, Inc. San Jose
|
||||
.sp
|
||||
Page 1
|
||||
.B2
|
||||
.SH "See Also"
|
||||
.B
|
||||
splittable
|
||||
.R
|
||||
.SO reportwriter
|
||||
+111
@@ -0,0 +1,111 @@
|
||||
.TH rmblank "" "" "/rdb Command"
|
||||
.PC "Remove blank rows from a table"
|
||||
\fBrmblank < \fItable\fR
|
||||
.PP
|
||||
.II "row^delete blank"
|
||||
.II "blank row^delete"
|
||||
.II delete
|
||||
.II replace
|
||||
The command
|
||||
.B rmblank
|
||||
deletes from
|
||||
.I table
|
||||
all input rows that consist of only white space (spaces and tabs).
|
||||
The related programs
|
||||
.B delete
|
||||
and
|
||||
.B replace
|
||||
blank out records.
|
||||
They can be used in transaction processing where the files
|
||||
are too large to process and several users are updating them.
|
||||
At a quiet time, the files can be compacted and reindexed.
|
||||
.PP
|
||||
Be sure to reindex any file that is processed by either
|
||||
.B rmblank
|
||||
or
|
||||
.B compress.
|
||||
.SH Example
|
||||
First we have table
|
||||
.BR inventory ,
|
||||
as follows:
|
||||
.DM
|
||||
Item Amount Cost Value Description
|
||||
---- ------ ---- ----- --------------
|
||||
1 3 50 150 rubber gloves
|
||||
2 100 5 500 test tubes
|
||||
3 5 80 400 clamps
|
||||
4 23 19 437 plates
|
||||
5 99 24 2376 cleaning cloth
|
||||
6 89 147 13083 bunsen burners
|
||||
7 5 175 875 scales
|
||||
.DE
|
||||
.PP
|
||||
Then we delete record 4
|
||||
.DM
|
||||
echo 4 | delete inventory Item
|
||||
.DE
|
||||
.PP
|
||||
and
|
||||
.B inventory
|
||||
now appears as follows:
|
||||
.DM
|
||||
Item Amount Cost Value Description
|
||||
---- ------ ---- ----- --------------
|
||||
1 3 50 150 rubber gloves
|
||||
2 100 5 500 test tubes
|
||||
3 5 80 400 clamps
|
||||
|
||||
5 99 24 2376 cleaning cloth
|
||||
6 89 147 13083 bunsen burners
|
||||
7 5 175 875 scales
|
||||
.DE
|
||||
.PP
|
||||
The command
|
||||
.B see
|
||||
shows the contents of
|
||||
.B inventory
|
||||
actually to be as follows:
|
||||
.DM
|
||||
Item^IAmount^ICost^IValue^IDescription $
|
||||
----^I------^I----^I-----^I--------------$
|
||||
1^I 3^I 50^I 150^Irubber gloves$
|
||||
2^I 100^I 5^I 500^Itest tubes$
|
||||
3^I 5^I 80^I 400^Iclamps$
|
||||
^I ^I ^I ^I $
|
||||
5^I 99^I 24^I 2376^Icleaning cloth$
|
||||
6^I 89^I 147^I13083^Ibunsen burners$
|
||||
7^I 5^I 175^I 875^Iscales$
|
||||
.DE
|
||||
.PP
|
||||
Now the command
|
||||
.DM
|
||||
rmblank < inventory
|
||||
.DE
|
||||
.PP
|
||||
removes lines that consist only of blanks.
|
||||
After we run this command,
|
||||
.B inventory
|
||||
appears as follows:
|
||||
.DM
|
||||
Item Amount Cost Value Description
|
||||
---- ------ ---- ----- --------------
|
||||
1 3 50 150 rubber gloves
|
||||
2 100 5 500 test tubes
|
||||
3 5 80 400 clamps
|
||||
5 99 24 2376 cleaning cloth
|
||||
6 89 147 13083 bunsen burners
|
||||
7 5 175 875 scales
|
||||
.DE
|
||||
.PP
|
||||
Remember to reindex a file after you run
|
||||
.B rmblank
|
||||
on it.
|
||||
.SH "See Also"
|
||||
.B
|
||||
compress,
|
||||
delete,
|
||||
index,
|
||||
replace,
|
||||
rmblank
|
||||
.R
|
||||
.SO rmblank
|
||||
@@ -0,0 +1,28 @@
|
||||
.TH rmcore "" "" "/rdb Command"
|
||||
.PC "Remove all core files"
|
||||
.B rmcore
|
||||
.PP
|
||||
.II core^remove"
|
||||
.II "remove core files"
|
||||
The command
|
||||
.B rmcore
|
||||
uses the COHERENT system's command
|
||||
.B find
|
||||
to search for files named
|
||||
.B core
|
||||
in the current directory and all subordinate directories.
|
||||
As its name implies, it removes all such files that it finds.
|
||||
.PP
|
||||
Run this command first when you begin to fill up your disk.
|
||||
.B rmcore
|
||||
starts at the directory you are in and goes down the file tree.
|
||||
If you are superuser, you can issue this
|
||||
command at the root directory `/' and clean the whole system.
|
||||
.SH "See Also"
|
||||
COHERENT Lexicon:
|
||||
.B
|
||||
core,
|
||||
find,
|
||||
rm
|
||||
.R
|
||||
.SO rmcore
|
||||
+189
@@ -0,0 +1,189 @@
|
||||
.TH row "" "" "/rdb Command"
|
||||
.PC "Make a new table where rows match logical condition"
|
||||
\fBrow '\fIcolumn condition column-or-value ..\fB' < \fItable\fR
|
||||
.PP
|
||||
.II "table^split"
|
||||
.II "table^create new"
|
||||
.II "row^select via expression"
|
||||
The command
|
||||
.B row
|
||||
creates a new table from
|
||||
.IR table .
|
||||
The new table
|
||||
consists of only those rows that meet
|
||||
.IR condition .
|
||||
.PP
|
||||
.B row
|
||||
uses a script written in the
|
||||
.B awk
|
||||
language, which gives you great power for specifying the logical condition.
|
||||
.PP
|
||||
Several conditional expressions can be combined with the
|
||||
logical AND (&&) and OR (||) operators.
|
||||
Because the logical conditions are represented by special characters,
|
||||
they must be enclosed by apostrophes, to protect them from being
|
||||
interpreted by the shell.
|
||||
If you have special characters within a column name,
|
||||
enclose the column name in quotation marks.
|
||||
.SH Example
|
||||
First a simple example.
|
||||
Consider table
|
||||
.B inventory :
|
||||
.DM
|
||||
Item Onhand Cost Value Description
|
||||
---- ------ ---- ----- -----------
|
||||
1 3 5 15 rubber gloves
|
||||
2 100 1 100 test tubes
|
||||
3 5 8 40 clamps
|
||||
4 23 2 51 plates
|
||||
5 99 2 97 cleaning cloth
|
||||
6 89 18 1602 bunsen burners
|
||||
7 5 175 875 scales
|
||||
.DE
|
||||
.PP
|
||||
To make a table of all of the parts that cost more that $5, type:
|
||||
.DM
|
||||
row 'Cost > 5' < inventory
|
||||
.DE
|
||||
.PP
|
||||
The new table appears as follows:
|
||||
.DM
|
||||
Item Onhand Cost Value Description
|
||||
---- ------ ---- ----- -----------
|
||||
3 5 8 40 clamps
|
||||
6 89 18 1602 bunsen burners
|
||||
7 5 175 875 scales
|
||||
.DE
|
||||
.PP
|
||||
Now a more complex example.
|
||||
If you want a table of all the burners
|
||||
and of all of the items of which we have fewer than ten in stock, type:
|
||||
.DM
|
||||
row 'Description ~ /burner/ || Onhand < 10' < inventory
|
||||
.DE
|
||||
.PP
|
||||
The new table appears as follows:
|
||||
.DM
|
||||
Item Onhand Cost Value Description
|
||||
---- ------ ---- ----- -----------
|
||||
1 3 5 15 rubber gloves
|
||||
3 5 8 40 clamps
|
||||
6 89 18 1602 bunsen burners
|
||||
7 5 175 875 scales
|
||||
.DE
|
||||
.PP
|
||||
The string
|
||||
.B "~ /burner/"
|
||||
searches for the string ``burner'' anywhere in the column.
|
||||
The double pipe (||) means logical OR.
|
||||
.SH "Column Names"
|
||||
The commands
|
||||
.BR row ,
|
||||
.BR compute ,
|
||||
and
|
||||
.B validate
|
||||
recognize column names as upper- and lower-case letters,
|
||||
digits, and the underscore `_'.
|
||||
The regular expression is [A-Za-z0-9_].
|
||||
If you have any other characters in your column names, put
|
||||
apostrophes or quotation marks around them.
|
||||
.PP
|
||||
.B row
|
||||
compares the recognized strings with the table's head line.
|
||||
Only if it finds a match does it convert the string
|
||||
to the \fB$1, $2...\fR column positions that
|
||||
.B awk
|
||||
needs.
|
||||
.SH "awk's Reserved Words"
|
||||
.B awk
|
||||
is the pattern-scanning language that does all of the work for the
|
||||
commands
|
||||
.BR row ,
|
||||
.BR compute ,
|
||||
and
|
||||
.BR validate .
|
||||
.PP
|
||||
.B awk
|
||||
recognizes the following words as having special significance.
|
||||
If you name a columns with any of these reserved words
|
||||
and then try to use them in a query, the
|
||||
.B /rdb
|
||||
commands that are built around
|
||||
.B awk
|
||||
turn them into column positions and
|
||||
.B awk
|
||||
does not see them.
|
||||
It is best to avoid these names as column heads or simply
|
||||
capitalize the first letter of each of your column names.
|
||||
.PP
|
||||
This list also indicates the many functions you have with
|
||||
.BR awk .
|
||||
However, do not rely on the following descriptions.
|
||||
The tutorial section of
|
||||
your COHERENT manual contains a summary of the
|
||||
.B awk
|
||||
language.
|
||||
.PP
|
||||
Please note that this list of
|
||||
.B awk
|
||||
functions and reserved words comes from UNIX System V.
|
||||
Other implementations of
|
||||
.B awk
|
||||
may not contain all of these functions.
|
||||
.DM
|
||||
.ta 1.5i
|
||||
\fIReserved Word Description\fR
|
||||
.tc .
|
||||
\fBBEGIN\fR Pattern that matches before first input record
|
||||
\fBEND\fR Pattern that matches after last input record
|
||||
\fBbreak\fR Exit the nearest \fBfor\fR or \fBwhile\fR loop
|
||||
\fBcontinue\fR Go to next iteration of \fBfor\fR or \fBwhile\fR loop
|
||||
\fBelse\fR Used in \fBif then else\fR expression
|
||||
\fBexit\fR Leave program entirely, as if at end of input
|
||||
\fBexp\fR Raise number to a power
|
||||
\fBfor\fR \fBfor (\fIexpression\fB ; \fIcondition\fB; \fIexpression\fB)\fR
|
||||
\fBgetline\fR Get next input line
|
||||
\fBif\fR \fBif (\fIcondition\fB) \fIstatement \fB[else \fIstatement\fB]\fR
|
||||
\fBin\fR \fBfor (\fIvariable \fBin \fIarray\fB) \fIstatement\fR
|
||||
\fBindex\fR \fBindex ( \fIstring1\fB, \fIstring2 \fB)\fR
|
||||
\fBint\fR Truncate argument to integer
|
||||
\fBlength\fR Return current line length, or length of argument
|
||||
\fBlog\fR Return log (to base 2) of argument
|
||||
\fBnext\fR Skip to next record and reexecute all commands
|
||||
\fBprint\fR Output variables
|
||||
\fBprintf\fR \fBprintf ("\fIformat\fB", \fIvariable\fB, ... )\fR
|
||||
\fBsplit\fR \fBsplit (\fIstring\fB, \fIarrayname\fB, \fIseparator\fB)\fR
|
||||
\fBsprintf\fR \fBsprintf ("\fIformat\fB", \fIvariable, ... \fB)\fR
|
||||
\fBsqrt\fR Return square root of argument
|
||||
\fBsubstr\fR \fBsubstr ( \fIstring\fB, \fIstart\fB, \fInumber \fB)\fR
|
||||
\fBwhile\fR \fBwhile ( \fIcondition\fB ) \fIstatement\fR
|
||||
.tc
|
||||
.DE
|
||||
.PP
|
||||
Although
|
||||
.B row
|
||||
is built around the
|
||||
.B awk
|
||||
language,
|
||||
.B row
|
||||
has the advantage of knowing about the names of the columns.
|
||||
Therefore, you can use column names instead
|
||||
of column positional numbers.
|
||||
To grasp the full power of
|
||||
.B row
|
||||
and
|
||||
.BR compute ,
|
||||
read the COHERENT manual's tutorial on
|
||||
.BR awk .
|
||||
.SH "See Also"
|
||||
.B
|
||||
compute,
|
||||
row,
|
||||
select,
|
||||
validate
|
||||
.R
|
||||
.br
|
||||
COHERENT Tutorials:
|
||||
.B
|
||||
Introduction to the awk Language
|
||||
.R
|
||||
+115
@@ -0,0 +1,115 @@
|
||||
.TH sale "" "" "/act/sales Command"
|
||||
.PC "Enter sale order, and item, update customer"
|
||||
.B sale
|
||||
.PP
|
||||
.II "sales order"
|
||||
The command
|
||||
.B sale
|
||||
is part of the accounting/sales system included with
|
||||
.BR /rdb .
|
||||
It enters a sales order into table
|
||||
.B saleorder
|
||||
and items into table
|
||||
.BR saleitem .
|
||||
It also permits an order-taker to add a new customer to
|
||||
the customer-information table
|
||||
.BR customer ,
|
||||
or to update information on an existing customer.
|
||||
.SH Example
|
||||
.B sale
|
||||
is interactive, to allow you to confirm each action.
|
||||
First, it asks for customer number.
|
||||
If you give it a number, it looks the number up in table
|
||||
.BR customer .
|
||||
If it finds a customer with that number, it displays information
|
||||
on that customer for you to confirm.
|
||||
If you do not have the customer's number, you can search with
|
||||
the slash string option or enter the question mark to enter
|
||||
.BR customer .
|
||||
There, you can search for the customer or add a new customer.
|
||||
.PP
|
||||
The following gives an example order-entry session:
|
||||
.DM
|
||||
MakeaPile, Inc. saleorder
|
||||
Enter Customer Number (? for new, /string search, Return to exit) \fB1\fP
|
||||
Vendor Number 1
|
||||
Mr. Luke Skywalker CEO
|
||||
.sp \n(pDu
|
||||
Rebel Enterprises
|
||||
123 Lea Street
|
||||
Space Port City, Far Side 123456789 Tatooy
|
||||
.DE
|
||||
.DM
|
||||
Code Qty
|
||||
------- -------
|
||||
\fBrdb 1\fP
|
||||
Order Number Code Backord Qty Price Total Name
|
||||
------- ------- ------- ------- ------- ------- ------- -------
|
||||
1 1 rdb 10 1 1500 1500.00 /rdb
|
||||
Number Cust Date Shipped Gross Tax Total
|
||||
------ ---- ------- ------- ------- ------- -------
|
||||
1 2 850723 0 1500.00 75.00 1575.00
|
||||
.DE
|
||||
.DM
|
||||
Is this correct? (y, n) \fBy\fP
|
||||
.DE
|
||||
.PP
|
||||
After you have confirmed the order, table
|
||||
.B sale
|
||||
modifies table
|
||||
.BR salesorder ,
|
||||
as follows:
|
||||
.DM
|
||||
Number Cust Date Shipped Gross Tax Total
|
||||
------ ---- ------- ------- ------- ------- -------
|
||||
1 2 850723 860525 1500.00 75.00 1575.00
|
||||
2 2 850724 860525 3000.00 150.00 3150.00
|
||||
3 3 850902 860525 22500.00 1125.00 23625.00
|
||||
4 3 850902 0 36000.00 1800.00 37800.00
|
||||
5 3 850902 0 21000.00 1050.00 22050.00
|
||||
.DE
|
||||
.PP
|
||||
It also modifies table
|
||||
.BR salesitem ,
|
||||
as follows:
|
||||
.DM
|
||||
Order Number Code Backord Qty Price Total Name
|
||||
------- ------- ------- ------- ------- ------- ------- ----
|
||||
1 1 rdb 10 1 1500 1500.00 /rdb
|
||||
2 1 rdb 10 2 1500 3000.00 /rdb
|
||||
3 1 rdb 10 5 1500 7500.00 /rdb
|
||||
3 2 act 10 10 1500 15000.00 /act
|
||||
4 1 rdb 10 5 1500 7500.00 /rdb
|
||||
4 2 rdb 10 19 1500 28500.00 /rdb
|
||||
5 1 rdb 10 5 1500 7500.00 /rdb
|
||||
5 2 act 10 9 1500 13500.00 /act
|
||||
.DE
|
||||
.PP
|
||||
Once you enter the correct customer number,
|
||||
.B sale
|
||||
gives you a table of items to enter.
|
||||
Type in
|
||||
.B Code
|
||||
and
|
||||
.BR Qty ,
|
||||
and the program looks up the other information in the inventory.
|
||||
Verify that the information is correct and make sure
|
||||
that you have enough in inventory to satisfy the order.
|
||||
Continue entering items until you are through.
|
||||
Pressing \fB<Return>\fR indicates that you are finished;
|
||||
.B sale
|
||||
then calculates the totals for the order, including tax.
|
||||
.PP
|
||||
This program uses the commands
|
||||
.B cursor
|
||||
and
|
||||
.B termput
|
||||
to maneuver about the screen.
|
||||
.SH "See Also"
|
||||
.B
|
||||
cursor,
|
||||
invoice,
|
||||
postar,
|
||||
termput
|
||||
.R
|
||||
.SO sale
|
||||
@@ -0,0 +1,58 @@
|
||||
.TH schema "" "" "/rdb Command"
|
||||
.PC "Print a table's schema"
|
||||
\fBschema \fItableorlist ...\fR
|
||||
.PP
|
||||
.II "table^print schema"
|
||||
.II "data base^print schema"
|
||||
The command
|
||||
.B schema
|
||||
prints the schema, or a data-base dictionary, for each
|
||||
.IR tableorlist .
|
||||
.PP
|
||||
Other data-base systems require that you define a schema
|
||||
prior to creating a table.
|
||||
In
|
||||
.BR /rdb ,
|
||||
you can derive a schema from an existing table or tables.
|
||||
.SH Example
|
||||
The following command combines the schemas for tables
|
||||
.B inventory
|
||||
and
|
||||
.BR maillist .
|
||||
The example pipes the concatenated schema through the command
|
||||
.B justify
|
||||
to ``pretty up'' the output:
|
||||
.DM
|
||||
schema inventory maillist | justify
|
||||
.DE
|
||||
.PP
|
||||
This produces the following:
|
||||
.DM
|
||||
Table Field Name
|
||||
--------- ----- -----------
|
||||
inventory 1 Item
|
||||
inventory 2 Amount
|
||||
inventory 3 Cost
|
||||
inventory 4 Value
|
||||
inventory 5 Description
|
||||
maillist 1 Number
|
||||
maillist 2 Name
|
||||
maillist 3 Company
|
||||
maillist 4 Street
|
||||
maillist 5 City
|
||||
maillist 6 State
|
||||
maillist 7 ZIP
|
||||
maillist 8 Phone
|
||||
.DE
|
||||
.PP
|
||||
Because
|
||||
.B schema
|
||||
is a shell script, you can modify it to give widths of columns,
|
||||
data types, and so on.
|
||||
.SH "See Also"
|
||||
.B
|
||||
datatype,
|
||||
precision,
|
||||
width
|
||||
.R
|
||||
.SO schema
|
||||
+190
@@ -0,0 +1,190 @@
|
||||
.TH screen "" "" "/rdb Command"
|
||||
.PC "Convert a form into a screen-input shell program"
|
||||
\fBscreen < \fIform\fB > \fIshellprogram\fR
|
||||
.PP
|
||||
.II "screen^make input form"
|
||||
The command
|
||||
.B screen
|
||||
reads
|
||||
.I form
|
||||
and writes a COHERENT shell program that paints the screen and reads
|
||||
a user's input.
|
||||
Because the output of
|
||||
.B screen
|
||||
is a shell script, you can edit it to validate data,
|
||||
read data and write it onto the screen, and so on.
|
||||
.I form
|
||||
must be in the same format as described in the manual entry for the command
|
||||
.BR report .
|
||||
.PP
|
||||
.B screen
|
||||
writes a simple shell script.
|
||||
The script works ``as is'' to read data
|
||||
typed onto the screen and to write a standard table.
|
||||
It uses the
|
||||
.B /rdb
|
||||
command
|
||||
.B cursor
|
||||
to move to each input field on the screen.
|
||||
.PP
|
||||
A script output by
|
||||
.B screen
|
||||
can be used in many ways.
|
||||
You can use it as a form, to enter data into a new table.
|
||||
You can edit the script to have it append its output into an
|
||||
existing table,
|
||||
to pass its data via a pipe to another command, or to read
|
||||
data from a table and display them on the screen.
|
||||
Commands can be edited into the screen-form script.
|
||||
You can add calls to the
|
||||
.B /rdb
|
||||
command
|
||||
.BR validate ,
|
||||
to confirm that the user has added data that are at least sensible.
|
||||
You can even embed the script within another shell script, to perform
|
||||
screen entry for it.
|
||||
.SH "Setup Steps"
|
||||
To create a screen-entry form, do the following:
|
||||
.IP \fB1.\fR
|
||||
Use your text editor to write the screen-form file.
|
||||
.IP \fB2.\fR
|
||||
Run
|
||||
.B screen
|
||||
to read the form file.
|
||||
Redirect its output into the file in which you wish to store the form's
|
||||
executable script.
|
||||
.IP \fB3.\fR
|
||||
Edit the shell script to meet your requirements,
|
||||
such as adding validation, record locking, and so forth.
|
||||
.IP \fB4.\fR
|
||||
Run the executable shell script to input data and write a new table.
|
||||
.SH Example
|
||||
A simple form looks like this:
|
||||
.DM
|
||||
Mail List Entry Form
|
||||
<!date!>
|
||||
.sp \n(pDu
|
||||
Name : <Name> Company: <Company>
|
||||
Street: <Street>
|
||||
City : <City> State : <State> ZIP: <ZIP>
|
||||
Phone : <Phone>
|
||||
.DE
|
||||
.PP
|
||||
Everything is written to the screen except what is between angle brackets
|
||||
``<>'', which are variables to be input.
|
||||
Exclamation marks within angle brackets (e.g., \fB<!date!>\fR)
|
||||
mark commands to execute when the program is running.
|
||||
.PP
|
||||
When
|
||||
.B screen
|
||||
reads the above form and compiles it, it writes the following shell script:
|
||||
.DM
|
||||
: paint crt screen
|
||||
exec 1>/dev/tty
|
||||
cat <<SCREEN
|
||||
${CLEAR} Mail List Entry Form
|
||||
.DE
|
||||
.DM
|
||||
Name : Company:
|
||||
Street:
|
||||
City : State : ZIP:
|
||||
Phone :
|
||||
.DE
|
||||
.DM
|
||||
SCREEN
|
||||
.sp \n(pDu
|
||||
: read user input
|
||||
cursor 1 23 ; date;
|
||||
cursor 3 8 ; read Name;
|
||||
cursor 3 36 ; read Company;
|
||||
cursor 4 8 ; read Street;
|
||||
cursor 5 8 ; read City;
|
||||
cursor 5 36 ; read State;
|
||||
cursor 5 55 ; read ZIP;
|
||||
cursor 6 8 ; read Phone;
|
||||
.DE
|
||||
.DM
|
||||
: output table head
|
||||
exec 1>&2
|
||||
echo "Name Company Street City State ZIP Phone"
|
||||
echo "---- ------- ------ ---- ----- --- -----"
|
||||
: append row
|
||||
echo "$Name $Company $Street $City $State $ZIP $Phone"
|
||||
.DE
|
||||
.PP
|
||||
This shell progam is in three parts, each introduced by a comment:
|
||||
.IP "\fBpaint crt screen\fR"
|
||||
This section clears the screen, then paints the form onto it.
|
||||
.IP "\fBread user input\fR"
|
||||
This section
|
||||
moves the cursor to each input field, then waits for
|
||||
the user to enter a string of characters.
|
||||
Each field is linked to a column; that is, what the user types in that field
|
||||
will be written into the column to which the field is linked.
|
||||
.IP "\fBoutput table head\fR"
|
||||
The final section writes the new table in standard
|
||||
.B /rdb
|
||||
format; that is, a column header followed by the row of data entered by the
|
||||
user.
|
||||
.PP
|
||||
To let you use the screen program in a pipe,
|
||||
the generated commands send the interactive output to the screen through the
|
||||
standard output temporarily tied to
|
||||
.BR /dev/tty ,
|
||||
and to the output table through the standard-error device.
|
||||
To accomodate COHERENT's implementation of
|
||||
.BR exec ,
|
||||
you must tie the standard error to the standard output
|
||||
when you run the script screen has created.
|
||||
For example
|
||||
.DM
|
||||
mail.s > mail.t 2>&1
|
||||
.DE
|
||||
.PP
|
||||
The following shows the form compiled above, with example data:
|
||||
.B1
|
||||
Mail List Entry Form
|
||||
Wed Sep 4 14:09:30 EDT 1987
|
||||
.sp
|
||||
Name : Hi Ho Company:
|
||||
Street: 1st St.
|
||||
City : LA State : CA ZIP: 90024
|
||||
Phone : 213-555-1212
|
||||
.B2
|
||||
.PP
|
||||
The above input creates the following table:
|
||||
.PP
|
||||
.DM
|
||||
Name Company Street City State ZIP Phone
|
||||
---- ------- ------ ---- ----- --- -----
|
||||
Hi Ho HH Inc. 1st St. LA CA 90024 213-555-1212
|
||||
.DE
|
||||
.PP
|
||||
You can redirect output into a file or pipe.
|
||||
Here, it was directed into table
|
||||
.BR mail.t .
|
||||
You can use this table as its stands alone,
|
||||
or you can append it to another table by by piping it to the
|
||||
.B append
|
||||
command.
|
||||
For example:
|
||||
.DM
|
||||
mail.s 2>&1 | append mail.t
|
||||
.DE
|
||||
.SH "See Also"
|
||||
.B
|
||||
cursor,
|
||||
lock,
|
||||
unlock,
|
||||
validate
|
||||
.R
|
||||
.br
|
||||
COHERENT Lexicon:
|
||||
.B
|
||||
cat,
|
||||
echo,
|
||||
exec,
|
||||
ksh,
|
||||
read,
|
||||
sh
|
||||
.R
|
||||
+426
@@ -0,0 +1,426 @@
|
||||
.TH search "" "" "/rdb Command"
|
||||
.PC "Search a table"
|
||||
\fBsearch [-m[bhirs]] [\-hsnx +x] [\-l [2> \fIlocation\fB]] \fItableorlist \fB[\fIkeycolumn ...\fB] [ < \fIkeytable\fB ]\fR
|
||||
.PP
|
||||
.II "row^find quickly"
|
||||
The command
|
||||
.B search
|
||||
finds a row quickly.
|
||||
It searches
|
||||
.I tableorlist
|
||||
for each row in which the value
|
||||
.I keycolumn
|
||||
matches one or keys you supply.
|
||||
The key or keys can either be entered interactively,
|
||||
or read from
|
||||
.IR keytable .
|
||||
You must use the
|
||||
.B /rdb
|
||||
command
|
||||
.B index
|
||||
to index
|
||||
.I tableorlist
|
||||
before you can use
|
||||
.B search
|
||||
to search it.
|
||||
.PP
|
||||
By default, a key's value must match exactly the string within
|
||||
.IR keycolumn .
|
||||
The options
|
||||
.B \-x
|
||||
and
|
||||
.B +x
|
||||
modify this behavior; they are described below.
|
||||
.PP
|
||||
You can use
|
||||
.B search
|
||||
in any of several different ways.
|
||||
Because it reads the key values from the standard input,
|
||||
you can input the keys by typing them interactively at the terminal,
|
||||
by diverting the contents of
|
||||
.I keytable
|
||||
into it,
|
||||
or by piping the output of a command into it.
|
||||
Each method is demonstrated in the examples given below.
|
||||
Therefore, it is easy to use
|
||||
.B search
|
||||
on a command line or in a shell script.
|
||||
For example, the command
|
||||
.B domain
|
||||
is a shell script that uses
|
||||
.B search
|
||||
to speed its searches.
|
||||
If you use a pipe to pass data to
|
||||
.BR search ,
|
||||
think of a stream of keys going into it
|
||||
and a stream of matching rows coming out.
|
||||
.PP
|
||||
.B search
|
||||
can use a number of different methods of searching.
|
||||
There are advantages and disadvantages to each;
|
||||
different sizes and structures of tables are best suited to different
|
||||
methods of searching.
|
||||
If you are not sure which method to use, you can try them all
|
||||
on your
|
||||
.IR tableorlist .
|
||||
Use the COHERENT command
|
||||
.B time
|
||||
to find how long each method takes, then pick the one that
|
||||
runs the fastest.
|
||||
Another
|
||||
.B /rdb
|
||||
command,
|
||||
.BR timesearch ,
|
||||
runs each form of
|
||||
.B search
|
||||
on the sample
|
||||
.BR unixtable ,
|
||||
which is kept in directory
|
||||
.BR $RDB/demo .
|
||||
Because
|
||||
.B timesearch
|
||||
is a shell script, you can modify it to time the different methods
|
||||
for your own file.
|
||||
.PP
|
||||
The behavior of
|
||||
.B search
|
||||
depends upon which method of searching you choose.
|
||||
With some methods, it first searches
|
||||
another table (called the ``secondary index file'')
|
||||
built by the command
|
||||
.BR index .
|
||||
One method, sequential, searches every row in
|
||||
.IR tableorlist .
|
||||
.PP
|
||||
If you change
|
||||
.IR tableorlist ,
|
||||
such as when you add a new row or delete an old one, you must reindex it.
|
||||
If you develop application programs, you can have them update
|
||||
secondary index files to handle dynamic file-processing.
|
||||
.SH "Methods of Searching"
|
||||
The following describes the different methods of searching a table.
|
||||
Each method is introduced by the command-line option with which
|
||||
you can invoke it:
|
||||
.IP \fB\-m\fR
|
||||
.II "search^sequential
|
||||
Perform a sequential search.
|
||||
This is the default method.
|
||||
.IP \fB\-mb\fR
|
||||
.II search^binary
|
||||
Binary search.
|
||||
This first looks at the middle record of the file.
|
||||
If the key column's value is greater than that of the key that
|
||||
.B search
|
||||
is seeking, then
|
||||
.B search
|
||||
look at the record one quarter of the way through the file.
|
||||
.B search
|
||||
continues to bifurcate the table until it finds the row, or finds
|
||||
that the row is not there.
|
||||
.sp \n(pDu
|
||||
The method of searching
|
||||
requires that you first sort the table on the key column.
|
||||
.sp \n(pDu
|
||||
A binary search takes log(2)\fIn\fR accesses:
|
||||
.DS
|
||||
.ta 1.0iC 2.5iC
|
||||
\fIAccesses No. of Records\fR
|
||||
10 1 thousand
|
||||
20 1 million
|
||||
30 1 billion
|
||||
40 1 trillion
|
||||
.DE
|
||||
.sp \n(pDu
|
||||
Binary searching is a good method for searching tables
|
||||
that must remain sorted on the key column.
|
||||
.IP \fB\-mh\fR
|
||||
.II search^hash
|
||||
Hash searching.
|
||||
A hash search computes an address from the key and
|
||||
looks into a secondary file at that address.
|
||||
If the key matches,
|
||||
it retrieves the address of the row you want in the main file and then
|
||||
retrieves it.
|
||||
If the address
|
||||
.B search
|
||||
hashes to is empty (i.e., has a value of zero),
|
||||
then the key does not match and the row is not in the file.
|
||||
.sp \n(pDu
|
||||
Occasionally, another key is there that happens to hash
|
||||
to the same address;
|
||||
this is called a
|
||||
.IR collision .
|
||||
When a collision occurs,
|
||||
.B search
|
||||
will keep looking at
|
||||
subsequent entries in the secondary table until
|
||||
it either finds a match or finds an empty or deleted (\-1) entry.
|
||||
.sp \n(pDu
|
||||
A hash search usually takes two disk accesses when the
|
||||
hash table is half full.
|
||||
For this reason,
|
||||
.B /rdb
|
||||
sets up hash tables that are twice as large as the number
|
||||
of records being hashed.
|
||||
As the data table grows, it must be reindexed to keep the hash speed up.
|
||||
.sp \n(pDu
|
||||
Hashing is a good method for tables that are static or change only rarely.
|
||||
.IP \fB\-mi\fR
|
||||
.II search^inverted
|
||||
.II search^indexed
|
||||
Inverted or indexed searching.
|
||||
An inverted search uses a secondary file that must have been created by
|
||||
.BR index .
|
||||
This index table has two columns:
|
||||
the key column from the data table, sorted to allow binary searching;
|
||||
and the offset of each key-column value within the data table.
|
||||
When
|
||||
.B search
|
||||
finds the key in the index table's key column, it then uses value from
|
||||
the address column to retrieve the row from the data table
|
||||
in a single disk read.
|
||||
The inverted method takes a little longer than binary,
|
||||
but sorting the index file is much faster than sorting the data table.
|
||||
.IP \fB\-mr\fR
|
||||
.II search^record
|
||||
Record number searching.
|
||||
A record search simply retrieves the row requested.
|
||||
For example, if you enter `5', you will get the fifth row in the data table.
|
||||
.sp \n(pDu
|
||||
To retrieve a record by its row number,
|
||||
.B search
|
||||
reads a secondary file that
|
||||
that contains the offset for each record in the data table.
|
||||
The record method is a faster way to retrieve a record;
|
||||
however, you must know the number of the record you want, and you must
|
||||
either keep the data table in that order, or reindex it.
|
||||
You can use the command
|
||||
.B replace
|
||||
to move a row to the of its table and update the secondary
|
||||
index to point to the row's new location.
|
||||
.IP \fB\-ms\fR
|
||||
.II search^sequential
|
||||
.II search^linear
|
||||
Sequential or linear searching.
|
||||
A sequential search examines all records in
|
||||
the data table in the order in which they appear.
|
||||
It is not a fast-access method, although it may
|
||||
still be faster than that used by the command
|
||||
.BR row .
|
||||
It is provided as a benchmark for timing other methods.
|
||||
If your file is not big enough to
|
||||
make the other access methods worthwhile, just use sequential
|
||||
.B search
|
||||
or
|
||||
.B row
|
||||
and save yourself the overhead of building and maintaining an index.
|
||||
.sp \n(pDu
|
||||
A sequential search can search multiple key columns, and and can search
|
||||
any column.
|
||||
.II grep
|
||||
The sequential method is better than the COHERENT command
|
||||
.B grep
|
||||
because it looks at one column, whereas
|
||||
.B grep
|
||||
scans the entire row for a pattern match.
|
||||
.SH "Other Options"
|
||||
.B search
|
||||
also recognizes the following command-line options:
|
||||
.IP \fB\-h\fR
|
||||
Do not print the table's head line.
|
||||
By default,
|
||||
.B search
|
||||
prints the head line of the table it searches as well as all rows it finds.
|
||||
The \fB\-h\fR option suppresses the printing of the head line
|
||||
and prints only the rows you are seeking.
|
||||
.IP \fB\-l\fR
|
||||
Output the location of the record in the data table
|
||||
and the location of the index record in the index table.
|
||||
.II replace
|
||||
.II lock
|
||||
.II unlock
|
||||
These locations is in the form
|
||||
.IR from to xfrom xto" ,
|
||||
and can be piped to the commands
|
||||
.BR replace ,
|
||||
.BR lock ,
|
||||
and
|
||||
.BR unlock .
|
||||
.B search
|
||||
writes these data to the standard-error device,
|
||||
to separate them from the table it writes to the standard output.
|
||||
.sp \n(pDu
|
||||
Because
|
||||
.B search
|
||||
is a shell program, it demonstrates how you can do this in your own programs.
|
||||
Turning on this option also turns on the
|
||||
.B \-s
|
||||
option because
|
||||
.B /rdb
|
||||
allows you to lock or replace one record at a time.
|
||||
Therefore, all keys in your file must be unique, or
|
||||
some will never be found.
|
||||
.IP \fB\-s\fR
|
||||
Search for only one row.
|
||||
This speeds the search because
|
||||
.B search
|
||||
quits when it finds the first match and continue searching the file.
|
||||
.IP \fB\-x\fR
|
||||
Partial match and case insensitive, like the Berkeley command \fBlook\fR.
|
||||
.IP \fB+x\fR
|
||||
Exact match, including blank characters.
|
||||
The default matching ignores blank characters.
|
||||
.SH Examples
|
||||
Assume you have a file called
|
||||
.BR inventory ,
|
||||
which appears as follows:
|
||||
.DM
|
||||
Item Amount Cost Value Description
|
||||
---- ------ ---- ----- --------------
|
||||
1 3 50 150 rubber gloves
|
||||
2 100 5 500 test tubes
|
||||
3 5 80 400 clamps
|
||||
4 23 19 437 plates
|
||||
5 99 24 2376 cleaning cloth
|
||||
6 89 147 13083 bunsen burners
|
||||
7 5 175 875 scales
|
||||
.DE
|
||||
.PP
|
||||
If you had indexed the column
|
||||
.BR Description ,
|
||||
then you have several ways to find rows:
|
||||
.IP \fB1.\fR 0.3i
|
||||
Interactively type key values.
|
||||
.B search
|
||||
immediately prints the rows it finds.
|
||||
For example, type:
|
||||
.DM
|
||||
search -mh inventory Description
|
||||
.DE
|
||||
.sp \n(pDu
|
||||
.B search
|
||||
responds with the head line of the inventory table.
|
||||
Now you can type names, in this example
|
||||
.BR scales ;
|
||||
if
|
||||
.B search
|
||||
finds a match, it returns the row that contains the key.
|
||||
.IP \fB2.\fR
|
||||
Divert a table or list file to
|
||||
.BR search .
|
||||
You can create a table with a column of key values; for example:
|
||||
.DM
|
||||
Description
|
||||
-----------
|
||||
scales
|
||||
clamps
|
||||
.DE
|
||||
.sp \n(pDu
|
||||
The following command line diverts this table into
|
||||
.B search
|
||||
.DM
|
||||
search -mh inventory Description < description
|
||||
.DE
|
||||
.sp \n(pDu
|
||||
and produces the following output:
|
||||
.DM
|
||||
Item Amount Cost Value Description
|
||||
---- ------ ---- ----- --------------
|
||||
7 5 175 875 scales
|
||||
3 5 80 400 clamps
|
||||
.DE
|
||||
.IP \fB3.\fR
|
||||
Input keys through a COHERENT pipe.
|
||||
For example, the command
|
||||
.DM
|
||||
column Description < sometable | search -mh inventory | column Value
|
||||
.DE
|
||||
.sp \n(pDu
|
||||
returns the following:
|
||||
.DM
|
||||
Value
|
||||
-----
|
||||
875
|
||||
400
|
||||
.DE
|
||||
.sp \n(pDu
|
||||
If you wish to justify a table like this, just pipe the output of
|
||||
.B search
|
||||
to the command
|
||||
.BR justify .
|
||||
.sp \n(pDu
|
||||
This lets you use the COHERENT command
|
||||
.B echo
|
||||
to pipe a key value:
|
||||
.DM
|
||||
echo scales | search -mh inventory Description
|
||||
.DE
|
||||
.sp \n(pDu
|
||||
which returns the following to the standard output:
|
||||
.DM
|
||||
Item Amount Cost Value Description
|
||||
---- ------ ---- ----- --------------
|
||||
7 5 175 875 scales
|
||||
.DE
|
||||
.PP
|
||||
In shell programming, you can capture the output of a program
|
||||
or a pipe by putting it within two grave (`) symbols.
|
||||
In a shell script, you can set an environmental variable like this:
|
||||
.DM
|
||||
RECORD=`echo key | search -mh -h bigtable column`
|
||||
.DE
|
||||
.PP
|
||||
The command
|
||||
.B "echo $RECORD"
|
||||
displays the data diverted into this variable; for example:
|
||||
.DM
|
||||
7 5 175 875 scales
|
||||
.DE
|
||||
.PP
|
||||
Now the
|
||||
.B RECORD
|
||||
environmental variable is equal to the matching row in the table.
|
||||
Note the
|
||||
.B \-h
|
||||
is important to keep the head line from being written into
|
||||
.BR RECORD .
|
||||
.SH "Search vs. Select"
|
||||
.B search
|
||||
is important for application programs written in
|
||||
shell scripts, the C programming language, or other code.
|
||||
It can be used interactively, but the command
|
||||
.B row
|
||||
is much more powerful because it can seek combinations of logical conditions,
|
||||
regular expressions, and conditions such as
|
||||
.I "greater than,"
|
||||
whereas
|
||||
.B search
|
||||
needs a key (either exact or partial).
|
||||
But for pulling a row out of a big table,
|
||||
.B search
|
||||
can speed things up enough to be preferred.
|
||||
In summary,
|
||||
.B search
|
||||
is for high-speed access with keys, whereas
|
||||
.B row
|
||||
should be used to retrieve rows that match complex logical conditions
|
||||
and regular expressions.
|
||||
.SH "See Also"
|
||||
.B
|
||||
append,
|
||||
column,
|
||||
delete,
|
||||
index,
|
||||
replace,
|
||||
row,
|
||||
seek,
|
||||
update
|
||||
.R
|
||||
.br
|
||||
COHERENT Lexicon:
|
||||
.B
|
||||
egrep,
|
||||
grep,
|
||||
look,
|
||||
time
|
||||
.R
|
||||
@@ -0,0 +1,165 @@
|
||||
.TH searchtree "" "" "/rdb Command"
|
||||
.PC "Seek a string node in tree table"
|
||||
\fBsearchtree [-m[bhirs]] \fItable root goal column1 column2\fR
|
||||
.PP
|
||||
.II "directory^search"
|
||||
.II "tree^search"
|
||||
.II PROLOG
|
||||
The command
|
||||
.B searchtree
|
||||
searches
|
||||
.I table
|
||||
to see if string
|
||||
.I root
|
||||
in
|
||||
.I column1
|
||||
is associated with
|
||||
.I goal
|
||||
in
|
||||
.IR column2 .
|
||||
It returns
|
||||
TRUE to the shell if it find that
|
||||
.I root
|
||||
is associated with
|
||||
.IR goal ,
|
||||
or FALSE if it is not.
|
||||
.PP
|
||||
.I goal
|
||||
may be within
|
||||
.IR table ,
|
||||
in which case the COHERENT command
|
||||
.B grep
|
||||
can also find it;
|
||||
.BR searchtree ,
|
||||
however, will also see if
|
||||
.I goal
|
||||
be reached by a path from
|
||||
.IR root .
|
||||
.PP
|
||||
The options
|
||||
.B \-m[bhirs]
|
||||
name the fast-access method to use.
|
||||
The default is sequential (\fB\-ms\fR).
|
||||
See the entry for the command
|
||||
.B search
|
||||
for a full description of each method of searching.
|
||||
.PP
|
||||
.B searchtree
|
||||
is a breadth-first search that uses the
|
||||
.B search
|
||||
fast-access methods to find all of the children at each level of a tree.
|
||||
This is the kind of search often done in artificial intelligence programs.
|
||||
However,
|
||||
.B searchtree
|
||||
stores its data in a temporary file rather than in memory,
|
||||
so that it will work on very large data bases.
|
||||
.PP
|
||||
Because
|
||||
.B searchtree
|
||||
is a shell script, you can modify it to serve many kinds of searches.
|
||||
For example, you can add a message like
|
||||
.I yes/no
|
||||
or
|
||||
.IR true/false .
|
||||
You can also add shell code to print out a path.
|
||||
You might want to use heuristics to guide the search at each
|
||||
level, and side effects to update data or print messages along the way.
|
||||
.PP
|
||||
This kind of searching is also used by the PROLOG language.
|
||||
.BR searchtree ,
|
||||
however, differs from PROLOG in two significant respects.
|
||||
First, PROLOG must have its data base in memory, which
|
||||
limits the size of the database it can handle.
|
||||
Second, PROLOG uses depth-first searching, which requires it to backtrack.
|
||||
.SH Example
|
||||
Consider the tree represented by table
|
||||
.BR isa ,
|
||||
as follows:
|
||||
.DM
|
||||
Name Isa
|
||||
---- ---
|
||||
barbara human
|
||||
bill human
|
||||
evan human
|
||||
rod human
|
||||
human primate
|
||||
primate mammal
|
||||
cat mammal
|
||||
dog mammal
|
||||
mammal animal
|
||||
bird animal
|
||||
fish animal
|
||||
animal lifeform
|
||||
plant lifeform
|
||||
.DE
|
||||
.PP
|
||||
Remember that all trees, in fact all graphs, can be listed
|
||||
as tables when the nodes (vertices)
|
||||
that are connected by a line (arcs) that is on each row.
|
||||
A directional graph is handled by having one column be
|
||||
.B From
|
||||
and another be
|
||||
.BR To .
|
||||
.PP
|
||||
The following command uses
|
||||
.B searchtree
|
||||
to examine table
|
||||
.B isa
|
||||
to see if entity
|
||||
.B rod
|
||||
in column
|
||||
.B Name
|
||||
is of type
|
||||
.B lifeform
|
||||
as given in column
|
||||
.BR Isa :
|
||||
.DM
|
||||
searchtree isa rod lifeform Name Isa ; echo $?
|
||||
.DE
|
||||
.PP
|
||||
The command
|
||||
.B "echo $?"
|
||||
prints the value returned by
|
||||
.BR searchtree .
|
||||
In this case, you see `0' (or FALSE), because
|
||||
.B rod
|
||||
is not a
|
||||
.BR lifeform ;
|
||||
rather it (or he) is a
|
||||
.BR human .
|
||||
.PP
|
||||
Because
|
||||
.B searchtree
|
||||
returns only a status code, you can use it as a test condition.
|
||||
Your shell program could have a statement like this:
|
||||
.DM
|
||||
prompt "What is your name: "
|
||||
read NAME
|
||||
if searchtree isa $NAME lifeform Name Isa
|
||||
then
|
||||
echo "So, I am talking to a lifeform."
|
||||
else
|
||||
echo "So, I am talking to another machine."
|
||||
fi
|
||||
.DE
|
||||
.PP
|
||||
The following gives an sample exchange with this script; text in \fBbold\fR
|
||||
gives what the user types:
|
||||
.DM
|
||||
What is your name: \fBrod\fP
|
||||
So, I am talking to a lifeform.
|
||||
.DE
|
||||
.PP
|
||||
The result of the search of the tree was tested by the
|
||||
.B if
|
||||
statement, and used to decide which message to print.
|
||||
.SH "See Also"
|
||||
.B
|
||||
search
|
||||
.R
|
||||
.SH Notes
|
||||
.II COHware
|
||||
If you wish to experiment with PROLOG, volume 2 of
|
||||
.B COHware
|
||||
includes the source code to a PROLOG interpreter.
|
||||
.SO searchtree
|
||||
+68
@@ -0,0 +1,68 @@
|
||||
.TH see "" "" "/rdb Command"
|
||||
.PC "Display nonprinting as well as printing characters"
|
||||
\fBsee < \fItableorlist\fR
|
||||
.PP
|
||||
.II "file^display contents"
|
||||
The command
|
||||
.B see
|
||||
displays the contents of
|
||||
.IR tableorlist .
|
||||
Unlike the COHERENT command
|
||||
.BR cat ,
|
||||
.B see
|
||||
represents all nonprinting characters by converting
|
||||
them to the form
|
||||
\fB^\fIsome-printing-character\fR.
|
||||
It is essentially the same as the Berkeley UNIX commands
|
||||
.B see
|
||||
or
|
||||
.BR "cat -v" .
|
||||
.PP
|
||||
.B see
|
||||
is very useful for seeing if you have placed tabs into your tables or lists.
|
||||
Tabs print out as
|
||||
.B ^I
|
||||
because they are also
|
||||
obtained by typing \fB<ctrl-I>\fR.
|
||||
.B see
|
||||
is also helpful for finding nonprinting characters.
|
||||
.SH Example
|
||||
To see the if the tabs are placed correctly in table
|
||||
.BR badtable ,
|
||||
type:
|
||||
.DM
|
||||
see < badtable
|
||||
.DE
|
||||
.PP
|
||||
You'll see something like:
|
||||
.DM
|
||||
Date^IAccount^IDebit^ICredit^IDescription$
|
||||
------^I-------^I-------^I-------^I--------------------------$
|
||||
820102^I101^I25000^I^Icash from loan$
|
||||
820102^I211.1^I^I25000^Iloan number #378-14 Bank Amerigold$
|
||||
820103^I150.1 10000^I^Itest equipment from Zarkoff$
|
||||
820103^I101^I^I5000^Icash payment$
|
||||
820103^I211.2^I^I5000^Inote payable to Zarkoff Equipment$
|
||||
820104^I130^I30000^I^Iinventory - parts from CCPSC$
|
||||
820104^I201.1^I^I15000^Iaccounts payable to CCPSC$
|
||||
820104^I101^I^I15000^Icash payment to CCPSC for parts$
|
||||
.DE
|
||||
.SH "See Also"
|
||||
COHERENT Lexicon:
|
||||
.B
|
||||
ASCII
|
||||
.R
|
||||
.SH Notes
|
||||
.B see
|
||||
assumes ASCII characters with a value between 0 and 127.
|
||||
.B see
|
||||
adds 128 to negative characters and to characters with values greater
|
||||
than 127.
|
||||
It then adds the value of ASCII `A' to characters with a value less
|
||||
than that of a blank character (ASCII 32)
|
||||
so they map to the upper-case characters.
|
||||
.PP
|
||||
For example, NUL
|
||||
is printed as \fB^@\fR, a tab character as \fB^I\fR, and a form-feed character
|
||||
as \fB^L\fR.
|
||||
.SO see
|
||||
+124
@@ -0,0 +1,124 @@
|
||||
.TH seek "" "" "/rdb Command"
|
||||
.PC "Return the beginning and ending offset of a row"
|
||||
\fBseek [-m[bihrs]] [-o \fIoutfile\fB] \fItableorlist \fB[\fIkeycol...\fB] < \fIfile\fR
|
||||
.PP
|
||||
.II "row^find"
|
||||
.II "row^offset"
|
||||
.II "find row"
|
||||
The command
|
||||
.B seek
|
||||
returns the offsets of the beginning and end of a record in
|
||||
.IR tableorlist .
|
||||
It uses the command
|
||||
.B search
|
||||
with its location option
|
||||
.BR \-l .
|
||||
.PP
|
||||
The offset and size integers returned can be used by the
|
||||
.B replace
|
||||
to write a new record.
|
||||
They are also used by the commands
|
||||
.B lock
|
||||
and
|
||||
.B unlock
|
||||
to set and remove record locks.
|
||||
.SH Options
|
||||
.B seek
|
||||
recognizes the following options:
|
||||
.IP \fB-m[bhirs]\fR
|
||||
Fast access methods.
|
||||
See the manual entry for the command
|
||||
.B search
|
||||
for a full description of various search options and how you can invoke each.
|
||||
.IP \fB-o\fR
|
||||
Write the found record into
|
||||
.BR outfile .
|
||||
.SH Example
|
||||
Let's use
|
||||
.B seek
|
||||
on the table
|
||||
.BR inventory ,
|
||||
which is as follows:
|
||||
.DM
|
||||
Item Amount Cost Value Description
|
||||
---- ------ ---- ----- --------------
|
||||
1 3 50 150 rubber gloves
|
||||
2 100 5 500 test tubes
|
||||
3 5 80 400 clamps
|
||||
4 23 19 437 plates
|
||||
5 99 24 2376 cleaning cloth
|
||||
6 89 147 13083 bunsen burners
|
||||
7 5 175 875 scales
|
||||
.DE
|
||||
.PP
|
||||
The following command invokes
|
||||
.B seek
|
||||
to find row 5:
|
||||
.DM
|
||||
echo 5 | seek -mb inventory Item
|
||||
.DE
|
||||
.PP
|
||||
This writes the following to the standard output:
|
||||
.DM
|
||||
207 245 0 8
|
||||
.DE
|
||||
.PP
|
||||
This means that the record is 207 bytes into the file and that
|
||||
it is 38 bytes long, ending at byte 245.
|
||||
.PP
|
||||
The next example
|
||||
extracts a row from
|
||||
.BR inventory
|
||||
blanks it out, then writes the row back into
|
||||
.B inventory
|
||||
on top of the original row.
|
||||
First, extract the row:
|
||||
.DM
|
||||
LOCATION=`echo 5 | seek -mb -o tmp inventory Item`
|
||||
.DE
|
||||
.PP
|
||||
The location of the selected record is stored in environmental variable
|
||||
.BR LOCATION .
|
||||
The option
|
||||
.B "\-o tmp"
|
||||
writes the record with key equal to 5 into table
|
||||
.BR tmp ,
|
||||
which appears as follows:
|
||||
.DM
|
||||
Item Amount Cost Value Description
|
||||
---- ------ ---- ----- --------------
|
||||
5 99 24 2376 cleaning cloth
|
||||
.DE
|
||||
.PP
|
||||
The next command blanks the contents of
|
||||
.BR tmp ,
|
||||
then writes the blanked row back into
|
||||
.B inventory
|
||||
at the location stored earlier at
|
||||
.BR LOCATION :
|
||||
.DM
|
||||
blank < tmp | replace inventory $LOCATION
|
||||
.DE
|
||||
.PP
|
||||
.B inventory
|
||||
now appears as follows:
|
||||
.DM
|
||||
Item Amount Cost Value Description
|
||||
---- ------ ---- ----- --------------
|
||||
1 3 50 150 rubber gloves
|
||||
2 100 5 500 test tubes
|
||||
3 5 80 400 clamps
|
||||
4 23 19 437 plates
|
||||
.sp \n(pDu
|
||||
6 89 147 13083 bunsen burners
|
||||
7 5 175 875 scales
|
||||
.DE
|
||||
.SH "See Also"
|
||||
.B
|
||||
index,
|
||||
lock,
|
||||
replace,
|
||||
search,
|
||||
unlock
|
||||
.R
|
||||
.SO seek
|
||||
@@ -0,0 +1,31 @@
|
||||
.TH select "" "" "/rdb Command"
|
||||
.PC "Output selected rows"
|
||||
\fBselect '\fIcolumn condition column-or-value\fB' < \fItable\fR
|
||||
.PP
|
||||
.II "row^select by expression"
|
||||
The command
|
||||
.B select
|
||||
writes a new file that consists of the rows of
|
||||
.I table
|
||||
that match the expression
|
||||
.I condition
|
||||
in
|
||||
.IR column .
|
||||
.PP
|
||||
.B select
|
||||
is a link to the command
|
||||
.BR row .
|
||||
It is included for those users who prefer the name
|
||||
.B select
|
||||
(which is a relational theory name) to
|
||||
.BR row .
|
||||
.\"However, it conflicts with the Korn shell which also has a
|
||||
.\".B select
|
||||
.\"command.
|
||||
.\"We strongly recommend you use
|
||||
.\".B row
|
||||
.\"instead.
|
||||
.SH "See Also"
|
||||
.B
|
||||
row
|
||||
.R
|
||||
@@ -0,0 +1,172 @@
|
||||
.TH sorttable "" "" "/rdb Command"
|
||||
.PC "Sort a table by one or more columns"
|
||||
\fBsorttable [\fIsort options\fB] [\fIcolumnname ...\fB] < \fItableorlist\fR
|
||||
.PP
|
||||
.II "table^sort"
|
||||
The command
|
||||
.B sorttable
|
||||
uses the COHERENT command
|
||||
.B sort
|
||||
to sort
|
||||
.IR tableorlist .
|
||||
Unlike
|
||||
.BR sort ,
|
||||
it knows about table head lines and column names.
|
||||
.PP
|
||||
With
|
||||
.B sorttable ,
|
||||
you use the column names rather than column numbers, as in
|
||||
.BR sort .
|
||||
.B sorttable
|
||||
also tells
|
||||
.B sort
|
||||
to use tabs as field separators, instead of white space
|
||||
(i.e., blanks and tabs).
|
||||
.PP
|
||||
.B sorttable
|
||||
completely sorts by the first column you name.
|
||||
If there are any duplicate values in that column, it goes
|
||||
to the second column and sort on those values.
|
||||
It continues across the named columns until it either finds
|
||||
a column that consists of unique values, or it runs out of columns.
|
||||
For example, if you sort a ledger on columns
|
||||
.B Account
|
||||
and
|
||||
.BR Date ,
|
||||
.B sorttable
|
||||
sorts the entire table on
|
||||
column
|
||||
.BR Account ,
|
||||
and sorts by
|
||||
.B Date
|
||||
within each account.
|
||||
.PP
|
||||
If no columns are named,
|
||||
.B sorttable
|
||||
sorts
|
||||
.I tableorlist
|
||||
by all of its columns from left to right.
|
||||
.SH Options
|
||||
.B sorttable
|
||||
passes all the options you give it to
|
||||
.BR sort .
|
||||
See the entry for
|
||||
.B sort
|
||||
in the COHERENT manual's Lexicon for details on this command's options.
|
||||
.SH Example
|
||||
Consider table
|
||||
.BR inventory ,
|
||||
which is structured as follows:
|
||||
.DM
|
||||
Item# Amount Cost Value Description
|
||||
------- ------- ------- ------- ---------------
|
||||
1 3 5.00 15.00 rubber gloves
|
||||
2 100 0.50 50.00 test tubes
|
||||
3 5 8.00 40.00 clamps
|
||||
4 23 1.98 45.54 plates
|
||||
5 99 2.45 242.55 cleaning cloth
|
||||
6 89 14.75 1312.75 bunsen burners
|
||||
7 5 175.00 875.00 scales
|
||||
.DE
|
||||
.PP
|
||||
To see
|
||||
.B inventory
|
||||
sorted with the highest
|
||||
.B Cost
|
||||
items on top, type:
|
||||
.DM
|
||||
sorttable -n -r Cost < inventory
|
||||
.DE
|
||||
.PP
|
||||
This produces:
|
||||
.DM
|
||||
Item# Amount Cost Value Description
|
||||
------- ------- ------- ------- ---------------
|
||||
7 5 175.00 875.00 scales
|
||||
6 89 14.75 1312.75 bunsen burners
|
||||
3 5 8.00 40.00 clamps
|
||||
1 3 5.00 15.00 rubber gloves
|
||||
5 99 2.45 242.55 cleaning cloth
|
||||
4 23 1.98 45.54 plates
|
||||
2 100 0.50 50.00 test tubes
|
||||
.DE
|
||||
.PP
|
||||
Note that
|
||||
.B Cost
|
||||
is in reverse order (the
|
||||
.B \-r
|
||||
option) and that it was treated as a number (\fB\-n\fR option)
|
||||
instead of a character string.
|
||||
.PP
|
||||
If you use
|
||||
.B sorttable
|
||||
frequently, you should carefully study the
|
||||
COHERENT Lexicon entry for
|
||||
.BR sort .
|
||||
For example, you can control which columns
|
||||
.B sorttable
|
||||
sort on.
|
||||
If you name several columns,
|
||||
.B sort
|
||||
sees each column's numbers proceeded by a `+'.
|
||||
The `+' means ``start sorting on this column'', the hyphen `-' means
|
||||
``stop on the next column''.
|
||||
To see this, use the
|
||||
.B \-D
|
||||
(debug) option for
|
||||
.B sorttable.
|
||||
(By the way, it is because
|
||||
.B sort
|
||||
has a
|
||||
.B \-d
|
||||
option that we use a capital
|
||||
.B \-D
|
||||
for the debug option for the
|
||||
.B /rdb
|
||||
commands).
|
||||
For example, typing
|
||||
.DM
|
||||
sorttable -D Cost Description < inventory
|
||||
.DE
|
||||
.PP
|
||||
yields:
|
||||
.DM
|
||||
Item Onhand Cost Value Description
|
||||
------- ------- ------- ------- ---------------
|
||||
sorttable: command executed: sort -t' ' +2 -3 +4 -5
|
||||
2 100 1 100 test tubes
|
||||
4 23 2 51 plates
|
||||
5 99 3 297 cleaning cloth
|
||||
1 3 5 15 rubber gloves
|
||||
3 5 8 40 clamps
|
||||
6 89 18 1602 bunsen burners
|
||||
7 5 175 875 scales
|
||||
.DE
|
||||
.PP
|
||||
The line beginning with
|
||||
.B sort
|
||||
is the line passed to COHERENT.
|
||||
Note the
|
||||
.BR +1 ,
|
||||
.BR \-2 ,
|
||||
and so on.
|
||||
That tells
|
||||
.B sort
|
||||
to sort on columns 2 and 4 (where the first column is 0).
|
||||
Thus,
|
||||
.B sorttable
|
||||
correctly turns the column names you type into a
|
||||
.B sort
|
||||
command by looking up the column names in the table head line and
|
||||
converting them to column numbers for the COHERENT command
|
||||
.BR sort .
|
||||
.PP
|
||||
People are often confused by
|
||||
.B sort
|
||||
because it does not behave the way one would expect.
|
||||
Study its entry in the COHERENT Lexicon.
|
||||
.SH "See Also"
|
||||
COHERENT Lexicon:
|
||||
.B
|
||||
sort
|
||||
.R
|
||||
+108
@@ -0,0 +1,108 @@
|
||||
.TH soundex "" "" "/rdb Command"
|
||||
.PC "Convert a name into soundex code"
|
||||
\fBsoundex < \fIfile \fB> \fIfile\fB.x ; index -mb \fIfile.x\fB Soundex\fR
|
||||
.PP
|
||||
.II "file^convert to soundex"
|
||||
.II "string^convert to soundex"
|
||||
.II "Knuth, Donald"
|
||||
The command
|
||||
.B soundex
|
||||
creates a secondary index to
|
||||
.I file
|
||||
based on Knuth's soundex code.
|
||||
It is used by the
|
||||
.B /rdb
|
||||
command
|
||||
.B like
|
||||
to find a name that sounds like another name.
|
||||
.PP
|
||||
The output must be written into file
|
||||
\fIfile\fB.x\fR; then run the command
|
||||
.B index
|
||||
on column
|
||||
.B Soundex
|
||||
within
|
||||
.IB table .x
|
||||
to ensure a high-speed search.
|
||||
.SH Example
|
||||
Consider table
|
||||
.BR name ,
|
||||
which has many similar names in it:
|
||||
.DM
|
||||
Name
|
||||
----
|
||||
Abraham
|
||||
Abraham
|
||||
Ackerman
|
||||
Actor
|
||||
Adams
|
||||
Adams
|
||||
Adams
|
||||
Adams
|
||||
\&...
|
||||
.DE
|
||||
.PP
|
||||
Use
|
||||
.B soundex
|
||||
to create the secondary index file, as follows:
|
||||
.DM
|
||||
soundex < name > name.x ; index -mb name.x Soundex
|
||||
.DE
|
||||
.PP
|
||||
The soundex'd index file appears as follows:
|
||||
.DM
|
||||
.ta 1.0i
|
||||
Name Soundex
|
||||
---- -------
|
||||
Avila A140
|
||||
Avila A140
|
||||
Avila A140
|
||||
Abraham A160
|
||||
Abraham A160
|
||||
Aissen A220
|
||||
Ajeska A220
|
||||
Augustine A223
|
||||
\&...
|
||||
.DE
|
||||
.PP
|
||||
Now you can use the
|
||||
.B like
|
||||
command to find a name.
|
||||
For example, the command
|
||||
.DM
|
||||
like Manis name
|
||||
.DE
|
||||
.PP
|
||||
produces something like:
|
||||
.DM
|
||||
Name
|
||||
----
|
||||
Mann
|
||||
Mann
|
||||
Means
|
||||
Mink
|
||||
Monahan
|
||||
Moniz
|
||||
Mooney
|
||||
Mooney
|
||||
Munoz
|
||||
Munoz
|
||||
.DE
|
||||
.PP
|
||||
Or the command
|
||||
.DM
|
||||
like Schaffer name
|
||||
.DE
|
||||
.PP
|
||||
produces something like:
|
||||
.DM
|
||||
Name
|
||||
----
|
||||
Schaeffer
|
||||
Schaffer
|
||||
Schiffrin
|
||||
.DE
|
||||
.SH "See Also"
|
||||
.B
|
||||
like
|
||||
.R
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user