Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

turning text into paginated two-column format and pipe this into less

Tags:

unix

I want to read a long text file in two-column format on my terminal. This means that the columns must be page-aware, so that text at the bottom of the first column continues at the top of the second column, but text at the bottom of the second column continues at the beginning of the first column after a page-down.

I tried column and less to get this result, but with no luck. If I pipe the text into column, it produces two columns but truncates the text before it reaches the end of the file. And if I pipe the output of column into less, it also reverts back to single-column.

a2ps does what I want in the way of reformatting, but I would rather have the output in pure plain text, readable from the terminal, rather than a PostScript file that I would need to read in a PDF reader.

like image 302
dan Avatar asked Jan 17 '10 15:01

dan


1 Answers

You can use pr for this, eg.

ls /usr/src/linux/drivers/char/ | pr -2 |less
like image 131
Hasturkun Avatar answered Nov 06 '22 12:11

Hasturkun