MYSYSAD.COM

Paginate a File or Command Output for Printing

· Shell & text · Files & disks

There are times when you might need to print out documents that can span numerous pages. Often times, it's helpful to have the pages paginated with a detailed header (date, time, filename, and page number). The pr command can do these things. Here are some examples of its use.

Prints 5 Line Header and Trailer. It also provides date, time, filename, and page number.
# pr esofthub.txt | lp

Jan 9 08:52 2006 esofthub.txt Page 1

Suppresses 5 Line Header and Trailer. It also suppresses date, time, filename, and page number.
#pr -t esofthub.txt | lp

Double spaced and prints 5 Line Header and Trailer. It also provides date, time, filename, and page number.
# pr -d esofthub.txt | lp

Double spaced, numbered lines, and prints 5 Line Header and Trailer. It also provides date, time, filename, and page number.
# pr -dn esofthub.txt | lp

Lists a directory and prints its contents in 6 columns without a header
# ls | pr -t6 | lp

Lists a directory and starts printing on page 4 with a header
#ls | pr +4 | lp

Lists a directory and prints a modified header (filename is replaced with esofthub pagetest)
#ls | pr -h 'esofthub pagetest' | lp