Linux system uses commands to print files

  
                

Printing a file on a Linux system can use the pr command, and pr is a shorthand for print. However, it is best to use the command to do some processing on the file before printing. This article will introduce the Linux system to use the command to print the file.

If you want to print text files, it is best to handle it in advance, including adjusting margins, line height settings, set the title, etc., so print out documents more attractive and easy to read. Of course, you can print without processing, but it may be ugly.

Most Linux comes with two powerful text formatting tools, nroff and troff, but they are relatively old and use very few people. Interested readers can learn by themselves. This tutorial is no longer available. In-depth explanation.

First, pr command

The pr command is used to convert a text file into a format suitable for printing. It can divide a large file into multiple pages for printing, and for each page. Add a title.

The syntax of the pr command is as follows:

pr option(s) filename(s)

The pr command simply changes the display style and printout style of the file on the screen, and The file itself will not be changed. The following table shows several options for the pr command:

Option Description

-k Prints in several columns, defaulting to 1.

-d Double line spacing (not all versions of pr are valid).

-h “header” Set the title of each page.

-t Do not print the title and top and bottom margins.

-l PAGE_LENGTH How many rows are displayed per page. The default is a total of 66 lines per page, with 56 lines of text.

-o MARGIN The number of spaces indented per line.

-w PAGE_WIDTH When multi-column output, set the page width, the default is 72 characters.

For example, the food file contains a lot of food names, printed in two columns using the pr command, and set the title of each page to “Restaurants”.

First check the contents of the file:

$cat food

Sweet Tooth

Bangkok Wok

Mandalay

Afghani Cuisine

Isle of Java

Big Apple Deli

Sushi and Sashimi

Tio Pepe‘s Peppers

..... ...

$

Then print using the pr command:

$pr -2 -h “Restaurants” food

Nov 7 9:58 1997 Restaurants Page 1

Sweet Tooth Isle of Java

Bangkok Wok Big Apple Deli

Mandalay Sushi and Sashimi

Afghani Cuisine Tio Pepe’s Peppers< Br>

........

$ Previous123Next page Total 3 pages

Copyright © Windows knowledge All Rights Reserved