$ jointable -a1 ledger chart
prints all of the rows from ledger joined with those chart rows whose key columns match, or with blank columns where there is no match.
$ jointable -j1 Account -j2 account ledger chart
will join ledger and chart using the Account column from ledger and the account column from chart as the key columns. This option allows joining on any column defined in either file, even when they have different names and locations.
$ cat chart Account Name ------- ---- 100 Assets 101 Cash 111 Accounts Receivable 111.1 Allowance for Bad Debt 115 Notes Receivable 120 Deposits 130 Parts Inventory$ cat ledger Account Date Debit Credit ------- ---- ----- ------ 101 920102 25000 101 920103 5000 101 920104 15000 130 920104 30000 150.1 920103 10000 201.1 920104 15000 211.1 920102 25000 211.2 920103 5000
$ jointable ledger chart Account Date Debit Credit Name ------- ---- ----- ------ ---- 101 920102 25000 Cash 101 920103 5000 Cash 101 920104 15000 Cash 130 920104 30000 Parts Inventory 150.1 920103 10000 Test equipment 211.1 920102 25000 Notes Payable - BA 211.2 920103 5000 Notes Payable - Z Equip
The Name column has been added to the columns of the ledger table and the Account column is not repeated in the resulting table. Also, only those rows with matching Account column values are printed. When a table has several rows with repeated key values (in this case, Account 101), the resulting table will also repeat the key values.
If no column names are specified, jointable will use the first column in each table as the key column on which to join. If the key column is not the first column, it must be named on the command line. For example, consider the journal table, sorted on Account:
$ cat journal Date Account Debit Credit ---- ------- ----- ------ 920104 101 15000 920103 101 5000 920102 101 25000 920104 130 30000 920103 150.1 10000 920104 201.1 15000 920102 211.1 25000 920103 211.2 5000
To join it with chart:
$ jointable -j Account journal chart
This join works because the key column has the same name in both tables, even though it happens to be in a different position. Because the key column Account in chart is in the first (or default) position, another way to produce the same result as above is:
$ jointable -j1 Account journal chart Date Account Debit Credit Name ---- ------- ----- ------ ---- 920104 101 15000 Cash 920103 101 5000 Cash 920102 101 25000 Cash 920104 130 30000 Parts Inventory 920103 150.1 10000 Test equipment 920102 211.1 25000 Notes Payable - BA 920103 211.2 5000 Notes Payable - Z Equip
The -a option lets you see all of one or both tables whether or not there is a match.
$ jointable -a1 ledger chart Account Date Debit Credit Name ------- ---- ----- ------ ---- 101 920102 15000 Cash 101 920103 5000 Cash 101 920104 25000 Cash 130 920104 30000 Parts Inventory 150.1 920103 10000 Test equipment 201.1 920104 15000 211.1 920102 25000 Notes Payable - BA 211.2 920103 5000 Notes Payable - Z Equip
Account 201.1 from ledger shows up in the resulting table, even though it is not in chart. Placement of the standard input as the first or second table is indicated by the `-' option:
$ sorttable Account < journal | jointable - chart Date Account Debit Credit Name ------ ------- ----- ------ ------------------------- 920102 101 25000 Cash 920103 101 5000 Cash 920104 101 15000 Cash 920104 130 30000 Parts Inventory 920103 150.1 10000 Test equipment 920104 211.1 25000 Notes Payable - BA 920103 211.2 5000 Notes Payable - Z Equip
The `-' before chart indicates the table to be read from the standard input is the first or leftmost table to be joined and it will appear on the left side of the resulting table. SEE ALSO