Untitled Document
pr Command

pr - command prepares a file for printing by adding suitable headers , footers and formatted text .

Example 1 -

A simple invocation of pr command is to use it with a filename argument . pr adds five lines of amrgin at the top and five at the bottom . The header shows the date and time of last modification of the file long with the filename and page number .

   pr emp.csv      

Example 2 ( -t ) option to suppress headers and footers

Run above pr command with -t option which suppress header and footer .

   pr -t emp.csv     

Example 3 - ( -h ) option to add header of your choice .

You can have a header of your choice , while printing file just use -h otpion with pr command .

   pr -h " Employee Details " emp.csv   

Example 4 - adding double space to file ( -d ) option

-d option adds double space to a file .

  pr -d emp.csv 

Example 5 - adding offset lines by n spaces to a file ( -o ) option , increases left margin of page

Run below command see the results .

  pr -o 10  emp.csv 

Example 6 - dispalying line numbers ( -n ) option

The -n option dispalys line numbers of file

  pr -n  emp.csv 

Example 7 - combining pr options

  pr -t -n -d -o  5 emp.csv 

Example 8 one option

There is one option that uses a number prefixed by a + to rint from a specific page number . Another option ( -l ) sets the page length .

  pr +10 emp.csv ------------- Start printing from page 10
  pr -l 50 emp.csv --------- Page length set to 50 
Untitled Document