Can someone please answer below question.

Note: (Since i am unable to copy paste from my linux virtual box to windows, i have to use screenshots at some places, please excuse me for that)

Quote from my textbook

$ cat -n /etc/ profile | pr -d | lpr

The result should be a printout that might be handy for taking notes on the configuration file. One caveat, though: If the file contains lines that approach or exceed 80 characters in length, the result can be single lines that spill across two lines. The result will be disrupted page boundaries. As a workaround, you can set a somewhat short page length with -l and use -f to ensure that the printer receives form feeds after each page:

$ cat -n /etc/ profile | pr -dfl 50

So does above scenario mean exceeding 80 characters in single line ? If yes then i have already tried a scenario; where i have a line with 100 characters and i could not notice any difference with or without dfl argument in pr command. Below are the screenshots.

With dfl

enter image description here

Without dfl

enter image description here

The only difference between the 2 commands is double space due to -d argument. I hope i am clear in my above question. Please wish someone to explain textbook quote where it mentions how to handle caveat scenario ?

1 Answer 1


Line printers (and some printing terminals) in Unix's early years were designed to print 66 lines per page, with either 80 or 132 columns in a fixed-width typeface per line, on continuous paper forms. lpr did not format its stdin or file argument; it was up to other programs, such as pr or nroff to do the formatting. (lpr could also send the output of troff to a phototypesetter).

To accommodate the fold between pages and provide top and bottom margins that most people prefer, after every 56 lines of input pr will insert 5 blank lines to serve as a bottom margin and 4 blank lines plus a header line to serve as a top margin. If the -f option is given, then at the bottom of each page, pr will output a formfeed instead of 5 blank lines. A printer can typically process a formfeed, which mechanically jumps to the top of the next page, faster than a series of blank lines. [There is a program, whose name I've forgotten, that formats C source code and inserts a formfeed prior to the beginning of each function, so that each function starts at the top of a new page when you print it out.]

Lineprinters typically did not wrap lines that were longer than the page width they were designed to handle. But printing terminals and display terminals (and terminal emulators, which are predominant today) can either wrap or not wrap long lines, depending on configuration. (More precisely, you can configure what happens when a character is printed in the rightmost column: either keep the cursor/print head in that last column, or move it to the first column of the next line). Most people prefer wrapping so as not to lose information.

pr didn't originally do any wrapping of long lines; some newer versions do, or you can use the fmt program as a filter. pr does, however, support a configurable page length (the -l option), so if you're using a terminal or printer that wraps lines, you can guesstimate a smaller page length that will result in 56 or fewer actual lines per page being output and tell pr to use that.

That's what your example did; it told pr to assume a page is 50 lines of text instead of 56. If you wind up with more or fewer than 6 extra lines due to wrapping, you do not want pr to insert its usual 5 blank lines, as that will throw off the alignment of the following pages; you want it to output a formfeed, so that's why they added the -f option in your example.

  • So then -f argument is enough to handle the caveat ? The solution which the book has given $ cat -n /etc/ profile | pr -dfl 50 -d and -l arguments are not required. ? Apr 8, 2018 at 15:52
  • The -f option can absorb 4 or 5 unexpected additional lines; more than than and you'll get misalignment on the following page(s), unless you reduce the page length with -l. Apr 8, 2018 at 15:57
  • As a beginner its difficult for me to understand as i am unable to imagine it; unless i actually do some practical by printing it; which i cant do as i don't have a printer. If some how its possible for you to send some image snaps to make it more easy for me ? Apr 8, 2018 at 16:02
  • 1
    I haven't used a printing terminal since 1992, when we retired our last VAX. There may be a way to configure lpr to interpret pages as it did long ago (66 lines/page and obeying form feed) yet render them as PDF files. I'll look on Monday. Apr 8, 2018 at 18:58

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .