.TH trim "" "" "/rdb Command" .PC "Trim excess white space from a table" \fBtrim [-[l|n|ln] \fIcol...\fB][-r[\fIn\fB] \fIcol...\fB][\-t'\fIc\fB']...< \fItable\fR .PP .II "white space^trim from table" .II "table^trim white space" .II "column^trim white space" The command .B trim trims excess white space from each column in .IR table . This lets you print a wide table with the minimum width for each column. Please note that .B trim removes all tabs from .IR table , which renders it unreadable by any .B /rdb command, including .B trim itself. .PP .B trim without any options does the best it can to squeeze .I table without discarding any information. It make each column as wide as its widest column name or data item. You can also tell .B trim to reduce a column's width, even if it has to throw away characters. .PP Note that .B trim trim all columns, even if some are listed with the options. Most other .B /rdb commands, such as .BR justify , affect only the columns named on the command line \(em unless none are listed, in which case they do the same thing to all of them. .SH Options .B trim recognizes the following options: .IP \fIn\fR The number of characters remaining after the trim. .IP "\fB\-\fIn column ...\fR" Return only .I n characters from the left of .IR column . .IP "\fB\-l\fIn column ...\fR" Return only .I n characters from the left of .IR column . .IP "\fB\-r\fIn column ...\fR" Return only .I n characters from the right of column. .IP "\fB\-t\(aa\fIc\fB\(aa\fR" Use character .I c as the column separator. For example, you may want to keep the tab character so that the table can be used by other .B /rdb commands. .sp \n(pDu When use this option, remember that the COHERENT shell gives special treatment to certain characters, such as the tab and the vertical bar `|'. You must quote these characters by enclosing them between apostrophes. .PP The above options affect the columns named. The options are .I sticky, which means that you can follow an option with as many column names as you wish. .SH Example Consider, once again, table .BR inventory , which appears 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 trim it, type: .DM trim < inventory .DE .PP This prints the following: .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 Note that the length of the column names .B Item and .B Amount determined the width of their columns, but in all other columns the data determined the width. .PP To examine what .B trim did exactly, you can use the command .B see . For example: .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 Note that there are no tabs \fB^I\fR. This table is only for printing. Don't input or pipe this output to another .B /rdb command unless you use the .B -t option, which retains the tab as a column separator. .PP We can further squeeze the table with the options \fB\-\fIn\fR, \fB\-l\fIn\fR, and \fB\-r\fIn\fR. For example, the command .DM trim -1 Item < inventory .DE .PP reduces column .B Item to only one character. This produces the following: .DM I 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 Note that to reduce .I Item to one character, .B trim had to throw away all but the `I' of the column name .BR Item . Note that the other columns were trimmed normally. .PP Because options are sticky, you can name several columns after one option: For example, the command .DM trim -5 Item Amount Cost Description < inventory .DE .PP reduces the four named columns to a maximum of five characters. This produces the following: .DM Item Amoun Cost Value Descr ----- ----- ----- ------- ----- 1 3 5.00 15.00 rubbe 2 100 0.50 50.00 test 3 5 8.00 40.00 clamp 4 23 1.98 45.54 plate 5 99 2.45 242.55 clean 6 89 14.75 1312.75 bunse 7 5 175 875.00 scale .DE .PP You can use the option \fB\-r\fIn\fR both to save the .I n right characters of a column and to line up numbers on the right. For example, the command .DM trim -r3 Amount < inventory .DE .PP produces: .DM Item Amo 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 Note that the column name .B Amount has been reduced to .BR Amo . Also, the column is right justified as a result of removing the right three characters of each field in the column. .PP A complex trim might be done like this: .DM trim -1 Item -r3 Amount -r5 Cost -l7 Value Description < inventory .DE .PP This command produces: .DM I Amo Cost Value Descrip - --- ----- ------- ------- 1 3 5.00 15.00 rubber 2 100 0.50 50.00 test tu 3 5 8.00 40.00 clamps 4 23 1.98 45.54 plates 5 99 2.45 242.55 cleanin 6 89 14.75 1312.75 bunsen 7 5 175.0 875.00 scales .DE .PP We have squeezed this table a lot. .PP We have been working with an unjustified table. What if the table had been justified? First let's justify the table: .DM justify < inventory > tmp ; mv tmp inventory .DE .PP Now .B inventory is justified, 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 Now, if we trim, you see: .DM Item Amount Cost Value Description ---- ------ ------ ------- -------------- 5.0 15.00 rubber gloves 10 0.5 50.00 test tubes 8.0 40.00 clamps 2 1.9 45.54 plates 9 2.4 242.55 cleaning cloth 8 14.7 1312.75 bunsen burners 175.0 875.00 scales .DE .PP This mess results from trimming the right characters in the right justified columns .BR Item , .BR Amount , and .BR Cost . This preserved the blank spaces, which are to the left in each column, and threw away the data. One way to fix this is to tell .B trim that the columns are right justified, like this: .DM trim -r Item Amount Cost < inventory .DE .PP This produces: .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 You can also compress the file before piping it into .BR trim . For further compression, use the command: .DM trim -r1 Item -r3 Amount -r6 Cost -l11 Description < inventory .DE .PP This produces: .DM I Amo Cost Value Description - --- ---- ----- ----------- 1 3 5.00 15.00 rubber glov 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 cl 6 89 14.75 1312.75 bunsen burn 7 5 175.00 875.00 scales .DE .SH "See Also" .B compresss, justify, trimblank .R