35.17 Making Text in Columns with prThe pr command (43.7 ) is famous for printing a file neatly on a page - with margins at top and bottom, filename, date, and page numbers. It can also print text in columns: one file per column or many columns for each file. The -t option takes away the heading and margins at the top and bottom of each page. That's useful when you want data "pasted" into columns with no interruptions. 35.17.1 One File per Column: -mThe -m option reads all files on the command line simultaneously and prints each in its own column, like this: % pr
may use TAB characters between columns.
If that would be bad, you can pipe pr
's output through
expand
(41.4
)
.
Many versions of pr
have a 35.17.2 One File, Several Columns: -numberAn option that's a number will print a file in that number of columns. For instance, the -3 option prints a file in three columns. The file is read, line by line, until the first column is full (by default, that takes 56 lines). Next, the second column is filled. Then, the third column is filled. If there's more of the file, the first column of page 2 is filled - and the cycle repeats: % The columns aren't balanced - if the file will fit into one column, the other columns aren't used. You can change that by adjusting -l , the page length option; see the section below. 35.17.3 Order Lines Across Columns with -lDo you want to arrange your data across the columns, so that the first three lines print across the top of each column, the next three lines are the second in each column, and so on, like this? % Use the -l1 (page length 1 line) and -t (no title) options. Each "page" will be filled by three lines (or however many columns you set). You have to use -t ; otherwise, pr will silently ignore any page lengths that don't leave room for the header and footer. That's just what you want if you want data in columns with no headings. If you want headings too, pipe the output of pr through another pr : % The Also see paste (35.18 ) and cols (35.16 ) . Of course, programming languages like awk (33.11 ) and perl (37.1 ) can also make text into columns. - |
|